0.1+0.2==0.3 (False or True)?

·

2 min read

0.1+0.2==0.3 (False or True)?

Table of contents

No heading

No headings in the article.

What is it? Okay so it is False. Actually these numbers will be converted to their binary format for circuits to understand on and off states.

So 0.1 and 0.2 here are not 1/10 and 2/10.

Let's first understand binary and decimal system to make it clear.

Let's say we have to fill three empty places using decimal system, Decimal implies base 10,so rightmost place can be filled with 0 to 9(10 digits) , similarly second and third. But the combinations will be 10^3(0-999) For example 345 will be (3X10^2)+(4X10^1)+(5X10^0).

In case of binary it is base 2,

so for 0th place it is 0 or 1,after that it goes to 1st place.

let's write 3 using binary.

  • 0th place 0 or 1
  • then 2 but we can't write 2 so it will be 10
  • 3 would be next one 11.
  • what about 4,yes it is 100.

(1X2^1)+(1X2^0)=3

For a particular base division by powers of that base is representable otherwise it would be an endless fraction

Binary to Decimal- 110.001=1X2^2 + 1X2^1+0X2^0+0X2^(-1)+0X2^(-2)+1X2^(-3)=6.125

Decimal to binary conversion for non-fractions

decimal to binary.jpg Image Source:Google

Decimal to Binary-

  • n = 4.47, k = 3places
  • 0.47 X 2 = 0.94, Integral part: 0
  • 0.94 X 2 = 1.88, Integral part: 1
  • 0.88 X 2 = 1.76, Integral part: 1 so 100.011

So there is no way to exactly store 0.1 or 0.2 using the binary system.

Thank you for reading :)