Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^12: NaN outputby BrowserUk (Patriarch) |
on Mar 07, 2014 at 00:38 UTC ( [id://1077302]=note: print w/replies, xml ) | Need Help?? |
Hm. $x starts undefined
You set $x to the maximum unsigned integer value; it becomes an IV:
You add 2 to it, it overflows the IV, so perl converts it to an NV (NB: No NaN arises from the overflow of the IV.)
Then, you raise that NV to the power 35; and the NV overflows; resulting in an NV with the floating point value of positive infinity (1.#INF) (NB:the "result to large" error):
You then divide the NV 1.#INF, by itself, and you produce an indeterminate floating point value (1.#IND):
The (special form of) NaN was produced by operating upon (erroneous) floating point (NV) values; not integer (IV) overflow. NaN is a purely floating point concept, and cannot arise as a result of integer overflow. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|