Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Dates in Binary | Binary Numeral System
Numeral Systems 101

book
Dates in Binary

We used to present a time as a combination of four items like a year, month, day, and the time actually, you got acquainted with binary code; hence, you know that the maximum possible value for binary code is byte which includes 8 bits. Consequently 8 bits for 4 items-> 32 bits at all, so only 32 bits for storing our date and time.

The time started on the first of January in the year 1970 at 00:00:00 in this system and as you have noticed the time pass, and unfortunately the memory has different properties, one of them is to have a limit; therefore, in one day our time has to stop. Recent surveys proved that it is going to happen on the 19th of January in 2038 year. Maybe you will be a developer who will find the solution to this issue 🤖.

**It will be 2,147,483,647 seconds after 1 January 1970 in 20:45:52 19th of January in 2038 **

Aufgabe

Swipe to start coding

Convert 2,147,483,647 to the binary number. Note that here the American standard for writing numbers was used to better understand the value, but for python code, it is necessary to exclude all commas: python read commas as a separator, but you don't need to separate anything. Your task is still the same follow the algorithm and fill the gaps.

  1. Create an empty list for storing a converted binary_number.
  2. Define the loop that executes till the decimal_number is 0.
  3. Count the remainder of division decimal_number by 2.
  4. Append the remainder to the list of binary numbers.
  5. Decrease decimal_number by integer division by 2.
  6. Make the list of binary numbers reversed.

Lösung

decimal_number = 2147483647
binary_number = []
print("The number in decimal numeral system is: ", decimal_number)
while decimal_number != 0:
remainder = decimal_number % 2
binary_number.append(remainder)
decimal_number = decimal_number // 2
binary_number.reverse()
print("The number in binary numeral system is: ", binary_number)

Note

I suppose you recognized that it is 31 bits full, so one second left to Epochalypse😲.

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 7
decimal_number = 2147483647
# Create an empty list for storing a converted binary number
binary_number = ___
print("The number in decimal numeral system is:", decimal_number)
# Define the loop that executes till the decimal_number is zero
___ decimal_number ___:
# Count the remainder of division decimal_number by 2
remainder = ___
# Append the remainder to the list of binary numbers
___.___(remainder)
# Decrease decimal_number using integer division by 2
decimal_number = ___ ___
# Make the list of binary numbers reversed
___.___()
print("The number in binary numeral system is:", binary_number)
toggle bottom row
some-alt