lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master bad25695 2/5: Modernize some old-style commen


From: Greg Chicares
Subject: [lmi-commits] [lmi] master bad25695 2/5: Modernize some old-style comments
Date: Tue, 24 May 2022 22:18:38 -0400 (EDT)

branch: master
commit bad256956859a8fd047b268f3c3584ab05ff0ab8
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Modernize some old-style comments
---
 fdlibm.hpp     | 16 ++++++-------
 fdlibm_expm1.c | 74 +++++++++++++++++++++++++++++-----------------------------
 fdlibm_log1p.c | 50 +++++++++++++++++++--------------------
 3 files changed, 70 insertions(+), 70 deletions(-)

diff --git a/fdlibm.hpp b/fdlibm.hpp
index 64d9861e..28cac313 100644
--- a/fdlibm.hpp
+++ b/fdlibm.hpp
@@ -112,7 +112,7 @@ typedef union
 } ieee_double_shape_type;
 #endif // __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
 
-/* Get two 32 bit ints from a double.  */
+// Get two 32 bit ints from a double.
 
 #define EXTRACT_WORDS(ix0,ix1,d)                                \
 do {                                                            \
@@ -122,7 +122,7 @@ do {                                                        
    \
   (ix1) = ew_u.parts.lsw;                                       \
 } while (0)
 
-/* Get the more significant 32 bit int from a double.  */
+// Get the more significant 32 bit int from a double.
 
 #define GET_HIGH_WORD(i,d)                                      \
 do {                                                            \
@@ -152,7 +152,7 @@ static inline int32_t hi_int(double d)
 #   pragma GCC diagnostic pop
 #endif // defined __cplusplus && defined LMI_GCC
 
-/* Get the less significant 32 bit int from a double.  */
+// Get the less significant 32 bit int from a double.
 
 #define GET_LOW_WORD(i,d)                                       \
 do {                                                            \
@@ -168,7 +168,7 @@ static inline uint32_t lo_uint(double d)
     return i;
 }
 
-/* Get all in one, efficient on 64-bit machines.  */
+// Get all in one, efficient on 64-bit machines.
 
 #define EXTRACT_WORDS64(i,d)                                    \
 do {                                                            \
@@ -177,7 +177,7 @@ do {                                                        
    \
   (i) = gh_u.word;                                              \
 } while (0)
 
-/* Set a double from two 32 bit ints.  */
+// Set a double from two 32 bit ints.
 
 #define INSERT_WORDS(d,ix0,ix1)                                 \
 do {                                                            \
@@ -187,7 +187,7 @@ do {                                                        
    \
   (d) = iw_u.value;                                             \
 } while (0)
 
-/* Get all in one, efficient on 64-bit machines.  */
+// Get all in one, efficient on 64-bit machines.
 
 #define INSERT_WORDS64(d,i)                                     \
 do {                                                            \
@@ -196,7 +196,7 @@ do {                                                        
    \
   (d) = iw_u.value;                                             \
 } while (0)
 
-/* Set the more significant 32 bits of a double from an int.  */
+// Set the more significant 32 bits of a double from an int.
 
 #define SET_HIGH_WORD(d,v)                                      \
 do {                                                            \
@@ -206,7 +206,7 @@ do {                                                        
    \
   (d) = sh_u.value;                                             \
 } while (0)
 
-/* Set the less significant 32 bits of a double from an int.  */
+// Set the less significant 32 bits of a double from an int.
 
 #define SET_LOW_WORD(d,v)                                       \
 do {                                                            \
diff --git a/fdlibm_expm1.c b/fdlibm_expm1.c
index 05650a53..35e54eee 100644
--- a/fdlibm_expm1.c
+++ b/fdlibm_expm1.c
@@ -149,17 +149,17 @@
 static const double
 huge        = 1.0e+300,
 tiny        = 1.0e-300,
-o_threshold = 7.09782712893383973096e+02,/* 0x40862E42, 0xFEFA39EF */
-ln2_hi      = 6.93147180369123816490e-01,/* 0x3fe62e42, 0xfee00000 */
-ln2_lo      = 1.90821492927058770002e-10,/* 0x3dea39ef, 0x35793c76 */
-invln2      = 1.44269504088896338700e+00,/* 0x3ff71547, 0x652b82fe */
-        /* scaled coefficients related to expm1 */
+o_threshold = 7.09782712893383973096e+02, // 0x40862E42, 0xFEFA39EF
+ln2_hi      = 6.93147180369123816490e-01, // 0x3fe62e42, 0xfee00000
+ln2_lo      = 1.90821492927058770002e-10, // 0x3dea39ef, 0x35793c76
+invln2      = 1.44269504088896338700e+00, // 0x3ff71547, 0x652b82fe
+        // scaled coefficients related to expm1
 Q[] = { 1.0
-      ,-3.33333333333331316428e-02 /* BFA11111 111110F4 */
-      , 1.58730158725481460165e-03 /* 3F5A01A0 19FE5585 */
-      ,-7.93650757867487942473e-05 /* BF14CE19 9EAADBB7 */
-      , 4.00821782732936239552e-06 /* 3ED0CFCA 86E65239 */
-      ,-2.01099218183624371326e-07 /* BE8AFDB7 6E09C32D */
+      ,-3.33333333333331316428e-02 // BFA11111 111110F4
+      , 1.58730158725481460165e-03 // 3F5A01A0 19FE5585
+      ,-7.93650757867487942473e-05 // BF14CE19 9EAADBB7
+      , 4.00821782732936239552e-06 // 3ED0CFCA 86E65239
+      ,-2.01099218183624371326e-07 // BE8AFDB7 6E09C32D
 };
 
 #define one Q[0]
@@ -175,30 +175,30 @@ double fdlibm_expm1(double x)
     int32_t k,xsb;
     uint32_t hx;
 
-    hx  = hi_uint(x);           /* high word of x */
-    xsb = hx&0x80000000;        /* sign bit of x */
-    if(xsb==0) y=x; else y= -x; /* y = |x| */
-    hx &= 0x7fffffff;           /* high word of |x| */
+    hx  = hi_uint(x);           // high word of x
+    xsb = hx&0x80000000;        // sign bit of x
+    if(xsb==0) y=x; else y= -x; // y = |x|
+    hx &= 0x7fffffff;           // high word of |x|
 
-    /* filter out huge and non-finite argument */
-    if(hx >= 0x4043687A) {      /* if |x|>=56*ln2 */
-        if(hx >= 0x40862E42) {  /* if |x|>=709.78... */
+    // filter out huge and non-finite argument
+    if(hx >= 0x4043687A) {      // if |x|>=56*ln2
+        if(hx >= 0x40862E42) {  // if |x|>=709.78...
           if(hx>=0x7ff00000) {
             if(((hx&0xfffff)|lo_uint(x))!=0)
-                 return x+x;    /* NaN */
-            else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
+                 return x+x;    // NaN
+            else return (xsb==0)? x:-1.0; // exp(+-inf)={inf,-1}
           }
-            if(x > o_threshold) return huge*huge; /* overflow */
+            if(x > o_threshold) return huge*huge; // overflow
         }
-        if(xsb!=0) {            /* x < -56*ln2, return -1.0 with inexact */
-            if(x+tiny<0.0)      /* raise inexact */
-            return tiny-one;    /* return -1 */
+        if(xsb!=0) {            // x < -56*ln2, return -1.0 with inexact
+            if(x+tiny<0.0)      // raise inexact
+            return tiny-one;    // return -1
         }
     }
 
-    /* argument reduction */
-    if(hx > 0x3fd62e42) {       /* if  |x| > 0.5 ln2 */
-        if(hx < 0x3FF0A2B2) {   /* and |x| < 1.5 ln2 */
+    // argument reduction
+    if(hx > 0x3fd62e42) {       // if  |x| > 0.5 ln2
+        if(hx < 0x3FF0A2B2) {   // and |x| < 1.5 ln2
             if(xsb==0)
                 {hi = x - ln2_hi; lo =  ln2_lo;  k =  1;}
             else
@@ -206,19 +206,19 @@ double fdlibm_expm1(double x)
         } else {
         k  = invln2*x+((xsb==0)?0.5:-0.5);
         t  = k;
-        hi = x - t*ln2_hi;      /* t*ln2_hi is exact here */
+        hi = x - t*ln2_hi;      // t*ln2_hi is exact here
         lo = t*ln2_lo;
         }
         x  = hi - lo;
         c  = (hi-x)-lo;
     }
-    else if(hx < 0x3c900000) {  /* when |x|<2**-54, return x */
-        t = huge+x;             /* return x with inexact flags when x!=0 */
+    else if(hx < 0x3c900000) {  // when |x|<2**-54, return x
+        t = huge+x;             // return x with inexact flags when x!=0
         return x - (t-(huge+x));
     }
     else k = 0;
 
-    /* x is now in primary range */
+    // x is now in primary range
     hfx = 0.5*x;
     hxs = x*hfx;
 //  performance improvement: Naohiko Shimizu 19970825
@@ -229,7 +229,7 @@ double fdlibm_expm1(double x)
     r1 = R1 + h2*R2 + h4*R3;
     t  = 3.0-r1*hfx;
     e  = hxs*((r1-t)/(6.0 - x*t));
-    if(k==0) return x - (x*e-hxs); /* c is 0 */
+    if(k==0) return x - (x*e-hxs); // c is 0
     else {
         e  = (x*(e-c)-c);
         e -= hxs;
@@ -238,21 +238,21 @@ double fdlibm_expm1(double x)
             if(x < -0.25) return -2.0*(e-(x+0.5));
             else           return  one+2.0*(x-e);
         }
-        if (k <= -2 || k>56) {     /* suffice to return exp(x)-1 */
+        if (k <= -2 || k>56) {     // suffice to return exp(x)-1
             y = one-(e-x);
-            SET_HIGH_WORD(y, hi_uint(y) + (k<<20));    /* add k to y's 
exponent */
+            SET_HIGH_WORD(y, hi_uint(y) + (k<<20));    // add k to y's exponent
             return y-one;
         }
         t = one;
         if(k<20) {
-               SET_HIGH_WORD(t, 0x3ff00000 - (0x200000>>k)); /* t=1-2^-k */
+               SET_HIGH_WORD(t, 0x3ff00000 - (0x200000>>k)); // t=1-2^-k
                y = t-(e-x);
-               SET_HIGH_WORD(y, hi_uint(y) + (k<<20)); /* add k to y's 
exponent */
+               SET_HIGH_WORD(y, hi_uint(y) + (k<<20)); // add k to y's exponent
         } else {
-               SET_HIGH_WORD(t, (0x3ff-k)<<20);        /* 2^-k */
+               SET_HIGH_WORD(t, (0x3ff-k)<<20);        // 2^-k
                y = x-(e+t);
                y += one;
-               SET_HIGH_WORD(y, hi_uint(y) + (k<<20)); /* add k to y's 
exponent */
+               SET_HIGH_WORD(y, hi_uint(y) + (k<<20)); // add k to y's exponent
         }
     }
     return y;
diff --git a/fdlibm_log1p.c b/fdlibm_log1p.c
index d516901f..32b95f92 100644
--- a/fdlibm_log1p.c
+++ b/fdlibm_log1p.c
@@ -117,17 +117,17 @@
  */
 
 static const double
-ln2_hi  =  6.93147180369123816490e-01,  /* 3fe62e42 fee00000 */
-ln2_lo  =  1.90821492927058770002e-10,  /* 3dea39ef 35793c76 */
-two54   =  1.80143985094819840000e+16,  /* 43500000 00000000 */
+ln2_hi  =  6.93147180369123816490e-01, // 3fe62e42 fee00000
+ln2_lo  =  1.90821492927058770002e-10, // 3dea39ef 35793c76
+two54   =  1.80143985094819840000e+16, // 43500000 00000000
 Lp[] = {0.0 // not used
-       ,6.666666666666735130e-01 /* 3FE55555 55555593 */
-       ,3.999999999940941908e-01 /* 3FD99999 9997FA04 */
-       ,2.857142874366239149e-01 /* 3FD24924 94229359 */
-       ,2.222219843214978396e-01 /* 3FCC71C5 1D8E78AF */
-       ,1.818357216161805012e-01 /* 3FC74664 96CB03DE */
-       ,1.531383769920937332e-01 /* 3FC39A09 D078C69F */
-       ,1.479819860511658591e-01 /* 3FC2F112 DF3E5244 */
+       ,6.666666666666735130e-01 // 3FE55555 55555593
+       ,3.999999999940941908e-01 // 3FD99999 9997FA04
+       ,2.857142874366239149e-01 // 3FD24924 94229359
+       ,2.222219843214978396e-01 // 3FCC71C5 1D8E78AF
+       ,1.818357216161805012e-01 // 3FC74664 96CB03DE
+       ,1.531383769920937332e-01 // 3FC39A09 D078C69F
+       ,1.479819860511658591e-01 // 3FC2F112 DF3E5244
 };
 
 #define Lp1 Lp[1]
@@ -145,52 +145,52 @@ double fdlibm_log1p(double x)
     double hfsq,f,c,s,z,R,u,z2,z4,z6,R1,R2,R3,R4;
     int32_t k,hx,hu,ax;
 
-    hx = hi_int(x);                             /* high word of x */
+    hx = hi_int(x);                             // high word of x
     ax = hx&0x7fffffff;
 
     k = 1;
-    if (hx < 0x3FDA827A) {                      /* x < 0.41422  */
-        if(ax>=0x3ff00000) {                    /* x <= -1.0 */
-            if(x==-1.0) return -two54/zero;     /* log1p(-1)=+inf */
-            else return (x-x)/(x-x);            /* log1p(x<-1)=NaN */
+    if (hx < 0x3FDA827A) {                      // x < 0.41422
+        if(ax>=0x3ff00000) {                    // x <= -1.0
+            if(x==-1.0) return -two54/zero;     // log1p(-1)=+inf
+            else return (x-x)/(x-x);            // log1p(x<-1)=NaN
         }
-        if(ax<0x3e200000) {                     /* |x| < 2**-29 */
-            if(two54+x>zero                     /* raise inexact */
-                    &&ax<0x3c900000)            /* |x| < 2**-54 */
+        if(ax<0x3e200000) {                     // |x| < 2**-29
+            if(two54+x>zero                     // raise inexact
+                    &&ax<0x3c900000)            // |x| < 2**-54
                 return x;
             else
                 return x - x*x*0.5;
         }
         if(hx>0||hx<=((int32_t)0xbfd2bec3)) {
-            k=0;f=x;hu=1;                       /* -0.2929<x<0.41422 */
+            k=0;f=x;hu=1;                       // -0.2929<x<0.41422
         }
     }
     if (hx >= 0x7ff00000) return x+x;
     if(k!=0) {
         if(hx<0x43400000) {
             u  = 1.0+x;
-            hu = hi_int(u);                     /* high word of u */
+            hu = hi_int(u);                     // high word of u
             k  = (hu>>20)-1023;
-            c  = (k>0)? 1.0-(u-x):x-(u-1.0);    /* correction term */
+            c  = (k>0)? 1.0-(u-x):x-(u-1.0);    // correction term
             c /= u;
         } else {
             u  = x;
-            hu = hi_int(u);                     /* high word of u */
+            hu = hi_int(u);                     // high word of u
             k  = (hu>>20)-1023;
             c  = 0;
         }
         hu &= 0x000fffff;
         if(hu<0x6a09e) {
-            SET_HIGH_WORD(u, hu|0x3ff00000);    /* normalize u */
+            SET_HIGH_WORD(u, hu|0x3ff00000);    // normalize u
         } else {
             k += 1;
-            SET_HIGH_WORD(u, hu|0x3fe00000);    /* normalize u/2 */
+            SET_HIGH_WORD(u, hu|0x3fe00000);    // normalize u/2
             hu = (0x00100000-hu)>>2;
         }
         f = u-1.0;
     }
     hfsq=0.5*f*f;
-    if(hu==0) {                                 /* |f| < 2**-20 */
+    if(hu==0) {                                 // |f| < 2**-20
         if(f==zero) {
             if(k==0) return zero;
             else {c += k*ln2_lo; return k*ln2_hi+c;}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]