• Blackmist@feddit.uk
    link
    fedilink
    English
    arrow-up
    2
    ·
    6 months ago

    The issue is a lot of people use floating point numbers, but don’t even know it.

    How many programmers right now are using JS, the most popular language in the world? How many of them do you think understand floating point numbers and their theoretical levels of accuracy? How many of them are unknowingly using floating points to store currency values?

    How many of them could accurately predict the result of the following?

    • 2.99+1.52==4.51
    • 2.99+1.53==4.52
    • 2.99+1.54==4.53

    Now imagine that as code to make sure you’ve paid the right amount in an online store. I guarantee you there is code out there right now that won’t let you finish a sale if the total of the basket adds up a certain way.