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. · לחץ על הרץ כדי לראות את התוצא כאן.