MYSQL do wrong math with strings [duplicate]












-2
















This question already has an answer here:




  • Is floating point math broken?

    28 answers




Simple sql code gives strange result:



select '0.29'*100;


Result: 28.999999999999996



Another one:



select '0.28'*100;


Result: 28.000000000000004



What's going on? Is it a bug?



I couldn't find any other number that behaves like that.










share|improve this question















marked as duplicate by Amadan, High Performance Mark, Madhur Bhaiya, Giorgos Myrianthous, meowgoesthedog Nov 21 '18 at 8:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.























    -2
















    This question already has an answer here:




    • Is floating point math broken?

      28 answers




    Simple sql code gives strange result:



    select '0.29'*100;


    Result: 28.999999999999996



    Another one:



    select '0.28'*100;


    Result: 28.000000000000004



    What's going on? Is it a bug?



    I couldn't find any other number that behaves like that.










    share|improve this question















    marked as duplicate by Amadan, High Performance Mark, Madhur Bhaiya, Giorgos Myrianthous, meowgoesthedog Nov 21 '18 at 8:54


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      -2












      -2








      -2









      This question already has an answer here:




      • Is floating point math broken?

        28 answers




      Simple sql code gives strange result:



      select '0.29'*100;


      Result: 28.999999999999996



      Another one:



      select '0.28'*100;


      Result: 28.000000000000004



      What's going on? Is it a bug?



      I couldn't find any other number that behaves like that.










      share|improve this question

















      This question already has an answer here:




      • Is floating point math broken?

        28 answers




      Simple sql code gives strange result:



      select '0.29'*100;


      Result: 28.999999999999996



      Another one:



      select '0.28'*100;


      Result: 28.000000000000004



      What's going on? Is it a bug?



      I couldn't find any other number that behaves like that.





      This question already has an answer here:




      • Is floating point math broken?

        28 answers








      mysql string math






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 8:06







      Paulius Ščerbinskas

















      asked Nov 21 '18 at 8:05









      Paulius ŠčerbinskasPaulius Ščerbinskas

      41




      41




      marked as duplicate by Amadan, High Performance Mark, Madhur Bhaiya, Giorgos Myrianthous, meowgoesthedog Nov 21 '18 at 8:54


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Amadan, High Performance Mark, Madhur Bhaiya, Giorgos Myrianthous, meowgoesthedog Nov 21 '18 at 8:54


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          1














          Double is 32-bit, and when you output it's an int, it's 16 bit, and of course there's a loss of precision






          share|improve this answer






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Double is 32-bit, and when you output it's an int, it's 16 bit, and of course there's a loss of precision






            share|improve this answer




























              1














              Double is 32-bit, and when you output it's an int, it's 16 bit, and of course there's a loss of precision






              share|improve this answer


























                1












                1








                1







                Double is 32-bit, and when you output it's an int, it's 16 bit, and of course there's a loss of precision






                share|improve this answer













                Double is 32-bit, and when you output it's an int, it's 16 bit, and of course there's a loss of precision







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 '18 at 8:28









                LoGanLoGan

                111




                111

















                    Popular posts from this blog

                    How to change which sound is reproduced for terminal bell?

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents