erikwiffin / 0.30000000000000004

Floating Point Math Examples

Home Page:https://0.30000000000000004.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: What Version of c#/.Net Framework?

x2764tech opened this issue · comments

On .Net 4.6, Console.Writeline(0.1 + 0.2); outputs 0.3

This is because of the precision formatting. The following statement should output the expected result:

Console.WriteLine("{0:R}", 0.1 + 0.2);