4 ms·
> It is still floating point, which means you still need to really watch what you are doing, but it's very high precision. The key difference between a decimal
by couchand 7y ago
> It is still floating point, which means you still need to really watch what you are doing, but it's very high precision.
The key difference between a decimal type (in any language) (regardless whether it's fixed-point or floating-point) is that it's not BINARY floating point. Yes, you need to watch what you are doing (shouldn't you always?)... but you can limit analysis to the appropriate precision, without worrying about binary conversion artifacts like 0.3 isn't 0.3.
> In general though, if your application allows for it, you should store money using integers representing cents.
What you're describing is a poor man's fixed point. Much better to just use a fixed point decimal type so you don't need to remember to apply the scale factor everywhere.
In any case, you can't get around the need to determine a ceiling in your necessary precision.