I know that binary storage for floats cannot always store the exact value. I know that .NET Framework only displays up to 7 significant digits for floats, and uses the 8th to round the 7th. I also know that the full value is used in calculations.
example code:
var f1 = 461168601842738790f; // 461,168,608,714,686,464 (closest float)
var f2 = f1 * 3f; // 1,383,505,826,144,059,392
// 1,383,505,860,503,797,760 (closest float)
var l1 = (long)f1;
var l2 = (long)f2;
Console.WriteLine($"f1: {f1:#,###}\nl1: {l1:#,###}\n\nf2: {f2:#,###}\nl2: {l2:#,###}");
/* displays:
f1: 461,168,600,000,000,000
l1: 461,168,608,714,686,464
f2: 1,383,506,000,000,000,000
l2: 1,383,505,860,503,797,760
*/
We can see that the full value is used in math and conversions. So how can we force .NET Framework (c# in particular) to display the full float value as a string?
Casting to long isn't a good option as the value could be larger than a long or be a decimal value. I've tried various string formatting options, but can't seem to find a way to display the full float value.
N0see learn.microsoft.com/en-us/dotnet/standard/base-types/… and dotnetfiddle.net/BIOtdU