Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Dates in Binary
course content

Course Content

Numeral Systems 101

Dates in BinaryDates 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 **

Task

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.

Note

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

Everything was clear?

Section 1. Chapter 7
toggle bottom row
some-alt