I am storing monetary values, and I read that FLOAT has internal rounding problems (although I can’t say I ever noticed any problems) and that it is better to use DECIMAL.
So I have been using DECIMAL but when I try to set the value to 1 it is stored as 0.99. I will be using that value in JavaScript at some point, and I know that my JS calculations will be wrong because it is 0.99 not 1.00.
Why is it doing that and should I just use FLOAT?
You need
DECIMAL(4, 2)by the looks of things.DECIMAL(2, 2)only allows a range of-0.99 to 0.99The precision represents the number of significant digits that are stored for values, and the scale represents the number of digits that can be stored following the decimal point. so in your case you have not defined the column to allow any integer part at all.