MySQL - Value of 1 in DECIMAL(2, 2) is coming out as 0.99

前端 未结 1 1869
既然无缘
既然无缘 2021-01-17 17:17

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.<

相关标签:
1条回答
  • 2021-01-17 17:43

    You need DECIMAL(4, 2) by the looks of things. DECIMAL(2, 2) only allows a range of -0.99 to 0.99

    The 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.

    0 讨论(0)
提交回复
热议问题