mysql 取小數點 (truncate, round)

TRUNCATE(123.456, 1) = 123.4
TRUNCATE(123.456, 0) = 123
TRUNCATE(123.456, -1) = 120
TRUNCATE(-123.456, 1) = -123.4

TRUNCATE 不會四捨五入,請用 ROUND 代替

ROUND(345.678, 1) = 345.7
ROUND(344.678, -1) = 340
ROUND(345.678, -1) = 350

發表迴響