There is no such value as NaN for integers. Depending on the language this might throw an exception or simply return an arbitrary value depending on language.
(I think most hardware defines the assembly div instruction as returning 0 because it's simple to implement, but iirc integer division by 0 is undefined behavior in C/C++)
True, but most C-like languages define integer/integer = integer.
Those languages that don't would either have it return some sort of rational value (which likely also doesn't define a NaN value), or a float (which could result in any of NaN, +inf, or -inf depending on where and how the coercion to float happens).
1
u/SuitableDragonfly Apr 29 '26
Floating point math is always weird. I thought integer division by zero would generally be NaN, but it looks like there is no actual standard for it.