42
submitted 1 day ago* (last edited 1 day ago) by CombatWombatEsq@lemmy.world to c/programming@programming.dev

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

you are viewing a single comment's thread
view the rest of the comments
[-] arty@feddit.org 4 points 1 day ago

I wonder how it is with nan etc in other languages

[-] CombatWombatEsq@lemmy.world 2 points 1 day 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 3 points 8 hours 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.

this post was submitted on 14 Jan 2026
42 points (97.7% liked)

Programming

24410 readers
355 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS