• FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 month ago

    Double is not perfectly precise. It is quite literally a function that calculates what the value should be. There are converters to show the drift: https://www.h-schmidt.net/FloatConverter/IEEE754.html

    $40.01 is literally stored as 01000010001000000000101000111101 in a float type, which is literally stored as 40.009998321533203125. The margin of error goes up the larger the number.

    No you’re fundamentally misunderstanding what’s going on. Float isn’t “storing 40.01 but imprecisely”. That’s like saying an integer “stores 1.1 but imprecisely”. Floating point can’t represent the number 40.01. But that doesn’t matter because 4.0009999999999998 is easily accurate enough for any real world use.

    The story of Ariane 5

    This was caused by converting an f64 to i16 which caused an overflow and hardware exception. Irrelevant.

    How a Minor Calculation Error Cost Intel Half a Billion Dollars

    Hardware bug. Irrelevant.

    Wikipedia

    Literally says “The failure to intercept arose not from using floating point specifically”

    and asking the stock exchange

    I’m not talking about stock exchanges. Obviously they have extreme requirements. For most normal businesses and people f64 is fine.

    You’re repeating dogma without thinking about it.