I remember reading issues about certain math operations and the type double, but I forget when they would occur, or how I need to deal with them.
A “Bitcoin” is a float that has 8 decimal places. I’m assuming that I use they type double with it, and not any other kind (decimal, etc). Is this correct?
What other issues should I consider as I write, debug, and test an application that uses 8 decimal points?
If you are doing anything with money you should be using
decimal. You will be getting accuracy issues well before 8 decimal places, depending on the size of the number.As there is a fixed amount of space (number of significant figures)
floatcan represent numbers in the range -1 to +1 more accurately than it can numbers in the range 9,000 to 10,000 (say).Float only has 7 digits of precision this means that it can’t represent numbers down to 8 decimal places.
Double has 15-16 digits of precision so is more accurate but still not accurate enough for monetary calculations – particularly with large values.
If they call it a
floatthen it’s misleading. They probably mean “floating point type” whichfloatis only one.