I know JavaScript is a very special boi but c’mon, you’re embarrassing me in front of the wizards.

    • CombatWombatEsq@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      ·
      7 days ago

      I’d definitely read a blog post about this, so if you decide to look into it you should write something up and post it. Maybe it’s standards based?

      • arty@feddit.org
        link
        fedilink
        English
        arrow-up
        6
        ·
        6 days ago

        I don’t think I’ll dive deeper than quoting Wikipedia:

        Most fixed-size integer formats cannot explicitly indicate invalid data. In such a case, when converting NaN to an integer type, the IEEE 754 standard requires that the invalid-operation exception be signaled.

        For example in Java, such operations throw instances of java.lang.ArithmeticException.

        In C, they lead to undefined behavior, but if annex F is supported, the operation yields an “invalid” floating-point exception (as required by the IEEE standard) and an unspecified value.

        In the R language, the minimal signed value (i.e. 0x80000000) of integers is reserved for NA (Not available).[citation needed] Conversions from NaN (or double NA) to integers then yield a NA integer.

        Perl’s Math::BigInt package uses “NaN” for the result of strings that do not represent valid integers.