web analytics

How to check if two double values are equal in the code?

Options
@2017-08-02 13:18:37

The following calculation explains how to convert 0.1 in decimal notation to the binary number.

1/10 = 1.6/16

        = 1/16 + 0.6/16

        = 1/16 + 1.2/32

        = 1/16 + 1/32 + 0.2/32

        = 1/16 + 1/32 + 1.6/256

        = 1/16 + 1/32 + 1/256 + 1/512 + 1/4096 + 1/8192 + ....

        = 2-4 + 2-5 + 2-8 + 2-9 + 2-12 + 2-13 +....

So 0.1 in decimal notation is 0.000110011001100...in binary notation.

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com