2 ms·
Beyond Float and Double: A New C# Type to Push Floating-Point Precision Further
- Someone 6y agoIt may be a bit easier to implement that rolling something completely new on your own, but why would one do that this way, mixing a binary float with a decimal one, and forcing the decimal to be in the [0,1) range, giving up about a quarter of the bits in the decimal value and, on average, I guess about 5½ bits in the float part? For example, for positive numbers less than 1,000/1,000,000, adding those 64 bits for a double to a decimal only gets you 3/6 more decimal digits, or about 10/20 bits. Also, with typical floats, the interval between successive representable values doesn’t get lower the larger the absolute value gets, but here, as an example, the value 2^1000+10^-25 is representable exactly in this format, but 2^1000+1 isn’t.