Binary to denary · ثنائي عشري
Binary to denary
Convert a binary number, written as a string, to denary (base 10).
Read the bits from left to right. Each new bit doubles the value so far and then adds itself: for "101" the value goes 1, then 1 * 2 + 0 = 2, then 2 * 2 + 1 = 5. int("1") turns the character into the number 1.
ثنائي إلى عشري
حول رقماً ثنائياً، مكتوباً كسلسلة نصية، إلى عشري (الأساس 10).
اقرأ البتات من اليسار إلى اليمين. كل بت جديد يضاعف القيمة الحالية ثم يضيف نفسه: لـ "101" تذهب القيمة 1، ثم 1 * 2 + 0 = 2، ثم 2 * 2 + 1 = 5. int("1") يحول الحرف إلى الرقم 1.
Write to_denary(bits) that turns a string of 0s and 1s into its whole-number value, without using int(bits, 2). "1011" is 11. · اكتب to_denary(bits) يحول سلسلة من 0s و 1s إلى قيمتها كعدد صحيح، دون استخدام int(bits, 2). "1011" هي 11.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.