Python Methods and Functions

** **

** Suitable: **

To convert a decimal floating point number to binary, first convert the integer part to binary, then the fractional part to binary, and finally combine both results to get a definitive answer.

For the integer part, keep dividing the number by 2 and noting the remainder until the dividend is less than 2. If so, stop and copy all the rest together.

For the decimal part, keep multiplying the decimal part by 2 until you have 0 as a fractional part. After multiplying for the first time, write down the integral part and again multiply the decimal part of the new value by 2. Continue doing this until you reach the perfect number.

Above steps can be written as:

1 (base 10) = 1 (base 2) and .234 (base 10) = .0011 (base 2)Now, to get the binary of 1.234, merge both results as a complete number.

`(1) 10 = (1) 2`

[approx.]

(.234) 10 = (.0011) 2

(1.234) 10 = ( 1.0011 ...) 2

(1.234) 10 = (1.0011) 2

Below is the implementation:

` ` |

** Exit: **

Enter your floating point value: 1.234 Enter the number of decimal places of the result: 41.0011

Enter your floating point value: 11.234 Enter the number of decimal places of the result: 41011.0011

This book is an indispensable guide focuses on Machine Learning and R Programming, in an instructive and conversational tone which helps them who want to make their career in Big Data Analytics/ Data ...

10/07/2020

Data scientist has been called “the sexiest job of the 21st century,” presumably by someone who has never visited a fire station. Nonetheless, 23/09/2020

Python: - The Bible - 3 Manuscripts in 1 book:

- Python Programming For Beginners
- Python Programming For Intermediates
- Python Programming for Advanced

12/08/2021

A Practical Approach to Computer Algorithms Using Python® and C# Rod Stephens started out as a mathematician, but while studying at MIT, he discovered how much fun algorithms are. He took every al...

23/09/2020

X
# Submit new EBook