In my program this fragment:
trace.Log(
String.Format("a= {0:F10} b= {1:F10} a<b= {2}",
b.GetPixel(447, 517).GetBrightness(), (100F / 255F),
b.GetPixel(447, 517).GetBrightness() < (100F / 255F))
);
outputs this in Debug mode:
a= 0.3921569000 b= 0.3921569000 a<b= False
but this different result in Release mode:
a= 0.3921569000 b= 0.3921569000 a<b= True
Before I seek a way to get consistent arithmetic between the two modes, what code can I use to display the hidden precision in the varaible(s) that presumably contains the variation causing this discrepancy? Thanks.
There’s a standard numeric format string for exactly what you’re looking for:
"r"(for “round-trip”). It gives you a string with enough digits to guarantee that, when you parse it again, will exactly reproduce the same bits you started with.So instead of
{0:F10}, use{0:r}and you’ll get all the precision available.