I am currently learning C# using various resources and one of them is the book titled "C# in a Nutshell".
From Page 37 of the book:
Real Number Rounding Errors
float
and double
internally represent numbers in base 2. For this reason, only
numbers expressible in base 2 are represented precisely. Practically, this means
most literals with a fractional component (which are in base 10) will not be represented precisely. For example:
float tenth = 0.1f; // Not quite 0.1
float one = 1f;
Console.WriteLine (one - tenth * 10f); // -1.490116E-08
However, I cannot replicate this. In my case output of Console.WriteLine is exactly 0. I am kind of confused..is it that the example given in the book is not meant to be replicated and given just for some explanation? or it is something else?
I use Visual Studio 2017 with Microsoft .NET framework 4.7.
Update: Screenshot
I tried in Console application as well as in C# Interactive Window. In both the cases the answer is 0.