I think a perlbug report should be filed for this.

Thing is, there is not a lot that Perl can do about it, as it is the default (and preferred) behaviour for floating point.

In the code below, the bit pattern 0x0x7ff0000000000001 displays as SNaN, only when nothing has caused the value to be loaded into a floating point register.

As soon as the value is loaded into an FP register, it gets silently converted to a QNan; and if the operation causes the result to be stored back to memory, the bit pattern will have been changed to a QNaN pattern.

And, I've tried every combination of Exception Mask bits in the FP control word to change that behaviour and nothing does. I do not see how Perl could change that behaviour outside of emulating FP in software?

Note how both the displayed representation of the value and the bit pattern change as soon as *any* floating point operation is performed on the value:

#include <stdio.h> #include <float.h> typedef union { double d; __int64 i; } BITS64; int main( int argc, char ** argv ) { BITS64 x; __try { _controlfp( _EM_INVALID|_EM_DENORMAL|_EM_ZERODIVIDE|_EM_OVERFL +OW|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM ); x.i = 0x7ff0000000000001; printf( "as int: %I64u\n", x.i ); printf( "as dbl: %f\n", x.d ); x.d += 0.0; printf( "as dbl: %f\n", x.d ); printf( "as int: %I64u\n", x.i ); } __except( 1 ) { fprintf( stderr, "Exception caught!\n" ); exit( -1 ); } return 0; } /* C:\test>junk.exe as int: 9218868437227405313 as dbl: 1.#SNAN0 as dbl: 1.#QNAN0 as int: 9221120237041090561 */

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". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice. Not understood.

In reply to Re^2: unintentional conversion of signaling NaN to quiet NaN by BrowserUk
in thread unintentional conversion of signaling NaN to quiet NaN by pryrt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.