Search code examples
mysqldecimaldivide

MySQL broke result of divide to decimals


My problem is result of divide process in mysql.

Example:

SELECT FLOOR(0.232 / 0.00002200) * 0.00002200

Result:

0.23199000

AND i wait for 0.232, it mean right is 0.232 It very important for me the right math result, but i do not know how fix it, I will be grateful for your help.


Solution

  • 0.23199 is CORRECT

    The answer 0.23199 is correct; 0.232 / 0.00002200 is 10545.454545… so FLOOR() should provide 10545.

    10545 * 0.00002200 == 0.23199 therefore the 0.23199 is not incorrect.


    Addendum

    Due to downvote / comment challenging 10545 * 0.00002200 's product cannot end in '9'

      10545
    x    22
     ------
      21090
     21090
     ------
     231990