stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r660486 - /stdcxx/branches/4.2.x/etc/config/src/INFINITY.cpp
Date Tue, 27 May 2008 12:31:48 GMT
Author: faridz
Date: Tue May 27 05:31:45 2008
New Revision: 660486

URL: http://svn.apache.org/viewvc?rev=660486&view=rev
Log:
2008-05-27  Farid Zaripov  <farid_zaripov@epam.com>

	* etc/config/src/INFINITY.cpp (flt_qnan): Clear sign bit to obtain value of positive qnan.
	(dbl_qnan): Ditto.
	(ldbl_qnan): Ditto.

Modified:
    stdcxx/branches/4.2.x/etc/config/src/INFINITY.cpp

Modified: stdcxx/branches/4.2.x/etc/config/src/INFINITY.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/etc/config/src/INFINITY.cpp?rev=660486&r1=660485&r2=660486&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/etc/config/src/INFINITY.cpp (original)
+++ stdcxx/branches/4.2.x/etc/config/src/INFINITY.cpp Tue May 27 05:31:45 2008
@@ -165,6 +165,15 @@
 
     val.val /= flt_zero ();
 
+    // val.val can be +qnan or -qnan
+    // clear sign bit
+    if (e == big_endian) {
+        val.bits [0] &= '\x7f';
+    }
+    else {
+        val.bits [sizeof (val.val) - 1] &= '\x7f';
+    }
+
 #else   // if !defined (_RWSTD_NO_DBL_TRAPS)
 
     // floating point arithmetic traps
@@ -172,7 +181,7 @@
     // assume IEEE 754 floating point format
 
     if (e == big_endian) {
-        val.bits [0] = '\xff';
+        val.bits [0] = '\x7f';
         val.bits [1] = '\xc0';
         val.bits [2] = '\0';
         val.bits [3] = '\0';
@@ -181,7 +190,7 @@
         val.bits [0] = '\0';
         val.bits [1] = '\0';
         val.bits [2] = '\xc0';
-        val.bits [3] = '\xff';
+        val.bits [3] = '\x7f';
     }
 
 #endif   // _RWSTD_NO_DBL_TRAPS
@@ -355,6 +364,15 @@
 
     val.val /= dbl_zero ();
 
+    // val.val can be +qnan or -qnan
+    // clear sign bit
+    if (e == big_endian) {
+        val.bits [0] &= '\x7f';
+    }
+    else {
+        val.bits [sizeof (val.val) - 1] &= '\x7f';
+    }
+
 #else   // if !defined (_RWSTD_NO_DBL_TRAPS)
 
     // floating point arithmetic traps
@@ -362,7 +380,7 @@
     // assume IEEE 754 floating point format
 
     if (e == big_endian) {
-        val.bits [0] = '\xff';
+        val.bits [0] = '\x7f';
         val.bits [1] = '\xf8';
         val.bits [2] = '\0';
         val.bits [3] = '\0';
@@ -379,7 +397,7 @@
         val.bits [4] = '\0';
         val.bits [5] = '\0';
         val.bits [6] = '\xf8';
-        val.bits [7] = '\xff';
+        val.bits [7] = '\x7f';
     }
 
 #endif   // _RWSTD_NO_DBL_TRAPS
@@ -587,6 +605,18 @@
 
     val.val /= ldbl_zero ();
 
+    // val.val can be +qnan or -qnan
+    // clear sign bit
+    if (e == big_endian) {
+        val.bits [0] &= '\x7f';
+    }
+    else {
+        unsigned inx = sizeof (val.val) - 1;
+        // skip the trailing zero's
+        while (!val.bits [inx]) --inx;
+        val.bits [inx] &= '\x7f';
+    }
+
 #else   // if !defined (_RWSTD_NO_DBL_TRAPS)
 
     // floating point arithmetic traps
@@ -594,7 +624,7 @@
     // assume IEEE 754 floating point format
 
     if (e == big_endian) {
-        val.bits [ 0] = '\xff';
+        val.bits [ 0] = '\x7f';
         val.bits [ 1] = '\xff';
         val.bits [ 2] = '\x80';
         val.bits [ 3] = '\0';
@@ -627,7 +657,7 @@
         val.bits [12] = '\0';
         val.bits [13] = '\x80';
         val.bits [14] = '\xff';
-        val.bits [15] = '\xff';
+        val.bits [15] = '\x7f';
     }
 
 #endif   // _RWSTD_NO_DBL_TRAPS



Mime
View raw message