using System;
namespace ConsoleApplication3
{
namespace ConsoleApplication
{
public class Program
{
public static void Main()
{
double d = 1.0;
d -= 0.3;
d -= 0.2;
d += 0.2;
d += 0.2;
d += 0.2;
d += 0.2;
d += 0.2;
Console.WriteLine("Standard formatting: {0}", d);
Console.WriteLine("Internal Representation: {0:r}", d);
Console.WriteLine("Console WriteLine 0 decimals: {0:0}", d);
Console.WriteLine("0 decimals Math.Round: {0}", Math.Round(d, MidpointRounding.AwayFromZero));
Console.WriteLine("15 decimals then 0 decimals Math.Round: {0}", Math.Round(Math.Round(d, 15, MidpointRounding.AwayFromZero), MidpointRounding.AwayFromZero));
}
}
}
}
dXNpbmcgU3lzdGVtOwoKbmFtZXNwYWNlIENvbnNvbGVBcHBsaWNhdGlvbjMKewogICAgbmFtZXNwYWNlIENvbnNvbGVBcHBsaWNhdGlvbgogICAgewogICAgICAgIHB1YmxpYyBjbGFzcyBQcm9ncmFtCiAgICAgICAgewogICAgICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGRvdWJsZSBkID0gMS4wOwogICAgICAgICAgICAgICAgZCAtPSAwLjM7CiAgICAgICAgICAgICAgICBkIC09IDAuMjsKICAgICAgICAgICAgICAgIGQgKz0gMC4yOwogICAgICAgICAgICAgICAgZCArPSAwLjI7CiAgICAgICAgICAgICAgICBkICs9IDAuMjsKICAgICAgICAgICAgICAgIGQgKz0gMC4yOwogICAgICAgICAgICAgICAgZCArPSAwLjI7CgogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlN0YW5kYXJkIGZvcm1hdHRpbmc6IHswfSIsIGQpOwogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIkludGVybmFsIFJlcHJlc2VudGF0aW9uOiB7MDpyfSIsIGQpOwogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIkNvbnNvbGUgV3JpdGVMaW5lIDAgZGVjaW1hbHM6IHswOjB9IiwgZCk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiMCBkZWNpbWFscyBNYXRoLlJvdW5kOiB7MH0iLCBNYXRoLlJvdW5kKGQsIE1pZHBvaW50Um91bmRpbmcuQXdheUZyb21aZXJvKSk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiMTUgZGVjaW1hbHMgdGhlbiAwIGRlY2ltYWxzIE1hdGguUm91bmQ6IHswfSIsIE1hdGguUm91bmQoTWF0aC5Sb3VuZChkLCAxNSwgTWlkcG9pbnRSb3VuZGluZy5Bd2F5RnJvbVplcm8pLCBNaWRwb2ludFJvdW5kaW5nLkF3YXlGcm9tWmVybykpOwogICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQo=