r - Why does NaN^0 == 1 -
prompted spot of earlier code golfing why would:
>nan^0 [1] 1
it makes perfect sense na^0
1 because na
missing data, , any number raised 0 give 1, including -inf
, inf
. nan
supposed represent not-a-number, why so? more confusing/worrying when page ?nan
states:
in r, mathematical functions (including basic arithmetic), supposed work +/- inf , nan input or output.
the basic rule should calls , relations infs statements proper mathematical limit.
computations involving nan return nan or perhaps na: of 2 not guaranteed , may depend on r platform (since compilers may re-order computations).
is there philosophical reason behind this, or how r represents these constants?
this referenced in page referenced ?'nan'
"the iec 60559 standard, known ansi/ieee 754 floating-point standard.
http://en.wikipedia.org/wiki/nan."
and there find statement regarding should create nan:
"there 3 kinds of operations can return nan:[5] operations nan @ least 1 operand.
it particular c compiler, signified note referenced. gnu c documentation says:
http://www.gnu.org/software/libc/manual/html_node/infinity-and-nan.html
" nan, on other hand, infects calculation involves it. unless calculation produce same result no matter real value replaced nan, result nan."
so seems gnu-c people have different standard in mind when writing code. , 2008 version of ansi/ieee 754 floating-point standard reported make suggestion:
http://en.wikipedia.org/wiki/nan#function_definition
the published standard not free. if have access rights or money can here:
http://ieeexplore.ieee.org/xpl/mostrecentissue.jsp?punumber=4610933
Comments
Post a Comment