• smlckz@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    3 days ago

    Another way to check whether a number is NaN:

    const isNaN = res !== res;
    

    As NaN is the only value out there that is not equal to itself. See my other comment on this post for more: https://programming.dev/comment/17221245

    This comparison should work in every programming language out there that implements/respects/uses IEEE 754 floating point numbers.