• Arthur Besse@lemmy.mlOPM
        link
        fedilink
        English
        arrow-up
        4
        ·
        edit-2
        3 days ago

        And other times 0.1 + 0.2 = 0.3000004

        0.1 + 0.2 != 0.3000004

        You’re off by 0.000000399999999955991114575226674787700176239013671875

        (0.1 + 0.2 is actually 0.3000000000000000444089209850062616169452667236328125)

        (And 0.1 is actually 0.1000000000000000055511151231257827021181583404541015625, and so on. People unfamiliar with IEEE 754 may be surprised by the output of python -c 'print("%.60f" % 0.1)')

  • pleiades@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    3 days ago

    Funny meme, never got why they used a bias instead of two’s complement for the exponent though

    • CausticFlames@sopuli.xyz
      link
      fedilink
      arrow-up
      5
      ·
      2 days ago

      they could have used two’s complement for the exponent, but the biased exponent is objectively a better encoding for what floating point hardware needs to do.

      This is paraphrased like mad, but basically that means hardware can compare exponent fields as plain unsigned integers. With twos complement, unsigned comparison says 255 > 1, even though -1 < 1. So every comparison would need special signed comparison logic.