Changes between Initial Version and Version 1 of Ticket #13018, comment 19


Ignore:
Timestamp:
Oct 15, 2014, 4:56:55 AM (3 years ago)
Author:
cypherpunks
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #13018, comment 19

    initial v1  
    1 More to puzzle. Output of testing sample linked with x86 libm (not reproducible for cross compiling):
    2 {{{
    3 Before FIX_FPU: tan(-1e300) = -1.421449, tan(strtod('-1e300')) = -4.802497
    4 After  FIX_FPU: tan(-1e300) = -1.421449, tan(strtod('-1e300')) = 0.883149
    5 }}}
    6 
    7 Code of sample:
    8 {{{
    9 #include <stdio.h>
    10 #include <stdlib.h>
    11 #include <math.h>
    12 
    13 inline void FIX_FPU() {
    14     short control;
    15     asm("fstcw %0" : "=m" (control) : );
    16     control &= ~0x300; // Lower bits 8 and 9 (precision control).
    17     control |= 0x2f3;  // Raise bits 0-5 (exception masks) and 9 (64-bit precision).
    18     asm("fldcw %0" : : "m" (control) );
    19 }
    20 
    21 int main () {
    22 char *end;
    23 double x;
    24 
    25 x = strtod ("-1e300", &end); // eq "x=-1e300";
    26 
    27 printf("Before FIX_FPU: tan(-1e300) = %f, tan(strtod('-1e300')) = %f\n", tan(-1e300), tan(x));
    28 FIX_FPU();
    29 printf("After  FIX_FPU: tan(-1e300) = %f, tan(strtod('-1e300')) = %f\n", tan(-1e300), tan(x));
    30 
    31 return 0;
    32 }
    33 }}}
    34 [https://mxr.mozilla.org/mozilla-esr24/source/js/src/jsnum.cpp#1019 FIX_FPU]
     1Non-informative. Confusing.