Posts

Showing posts with the label floating-point

Have computers started storing 0.1 correctly?

Have computers started storing 0.1 correctly? While learning about floating point arithmetic, I came across something, I quote: 'a float/double can't store 0.1 precisely". There is a question on SO pointing the same thing and accepted answer is also very convincing. However I thought of trying it out on my own computer, so I wrote following program as below double a = 0.1; if (a == 0.1) { Console.WriteLine("True"); } else { Console.WriteLine("False"); } Console.Read(); and console printed True . Shocking to as I was already convinced with something else. Can anyone tell me what's going on with floating point arithmetic? Or I just got a computer that store numeric values as base 10? True Given that it's stored inaccurately the same way both times you wrote it why wouldn't they be equal? – jonrsharpe Jul 1 at 7:55 ...