Page not loading? Try clicking here.
Placeholder

#4977

Binary Representation of a Real Number 1s 32MB

Problems

Timothy received a homework assignment to convert a decimal real number into binary.

He knew how to convert integers to binary, but he did not know how to convert real numbers (with fractional parts). After asking the teacher, he was taught the following method:

  • Method to convert a decimal real number to binary:

    1. Separate the number into its integer part and fractional part.

    2. Convert the integer part to binary using repeated division by 2.

    3. Convert the fractional part to binary by repeatedly multiplying by 2 and taking the integer part each time. Continue until the desired precision is reached.

    4. Combine the integer and fractional parts to form the binary representation.

Using this method, write a program that converts a decimal real number N into binary. Only keep the fractional part up to 4 digits after the binary point, truncating any remaining digits.


Input

A decimal real number N, where 0 < N < 100.


Output

Print the binary representation of N with the fractional part truncated to four binary digits.


Example #1

27.625
11011.1010

Example #2

1.123456
1.0001

Example #3

5.625
101.1010

Example #4

15.15
1111.0010


Source

klee

You must sign in to write code.