How to convert float number to Binary?

前端 未结 6 816
不思量自难忘°
不思量自难忘° 2020-12-07 16:53

Can anyone please tell me how can I convert this float number: 12.25 to binary? I know how to convert the \"12\" but not the 0.25

Any help is much appreciated. Thank

6条回答
  •  庸人自扰
    2020-12-07 17:34

    Keep multiplying the number after decimal by 2 till it becomes 1.0:

    0.25*2 = 0.50
    0.50*2 = 1.00
    

    and the result is in reverse order being .01

提交回复
热议问题