+ 1

How to calculate decimal part of a number in python

Iā€™m really new to python and Iā€™m currently learning about binary system For integer numbers python can calculate the binary form really nice but when it comes to decimal part of a number python gives me an error and itā€™s unable to calculate Why is that ? And what is the Solution? For example : https://code.sololearn.com/cqc3ovys15L6/?ref=app i want the binary of the whole number which is 110.00001... and python seems to be unable to calculate (i calculate this on paper) i mean how to calculate binary of a number which is less than 1 (like in this case 0.0588)

17th Mar 2021, 9:34 AM
Negarrezaei
Negarrezaei - avatar
3 Answers
+ 1
Check the solution https://code.sololearn.com/cgOVLjsECNA3/?ref=app I hope it helps
17th Mar 2021, 10:08 AM
!Derrickee
!Derrickee - avatar
+ 1
<Derrickee/> actually it didt cause i dont want the binary of the integer part , i want the binary of the whole number which is 110.00001... and python seems to be unable to calculate (i calculate this on paper) i mean how to calculate binary of a number which is less than 1 (like in this case 0.0588)
17th Mar 2021, 10:13 AM
Negarrezaei
Negarrezaei - avatar
+ 1
Python program to convert floating to binary" https://www.tutorialspoint.com/python-program-to-convert-floating-to-binary Read this article . I think the answer is in.Why you had that error. Thanks šŸ¤—
17th Mar 2021, 10:23 AM
!Derrickee
!Derrickee - avatar