Prompted by a spot of earlier code golfing why would:
>NaN^0
[1] 1
It makes perfect sense for NA^0 to be 1 because NA is missing data, and any number raised to 0 will give 1, including -Inf and Inf. However NaN is supposed to represent not-a-number, so why would this be so? This is even more confusing/worrying when the help page for ?NaN states:
In R, basically all mathematical functions (including basic
Arithmetic), are supposed to work properly with+/- InfandNaNas input or output.The basic rule should be that calls and relations with
Infs really are statements with a proper mathematical limit.Computations involving
NaNwill returnNaNor perhapsNA: which of those two is not guaranteed and may depend on the R platform (since compilers may re-order computations).
Is there a philosophical reason behind this, or is it just to do with how R represents these constants?