projects
/
libm
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
781e328
)
various minor style fixes
author
nsz
<nsz@port70.net>
Mon, 5 Mar 2012 21:51:04 +0000
(22:51 +0100)
committer
nsz
<nsz@port70.net>
Mon, 5 Mar 2012 21:51:04 +0000
(22:51 +0100)
12 files changed:
src/math/nextafter.c
patch
|
blob
|
history
src/math/nextafterf.c
patch
|
blob
|
history
src/math/nextafterl.c
patch
|
blob
|
history
src/math/nexttowardf.c
patch
|
blob
|
history
src/math/powl.c
patch
|
blob
|
history
src/math/remainder.c
patch
|
blob
|
history
src/math/remainderf.c
patch
|
blob
|
history
src/math/remquo.c
patch
|
blob
|
history
src/math/remquof.c
patch
|
blob
|
history
src/math/rint.c
patch
|
blob
|
history
src/math/scalbnl.c
patch
|
blob
|
history
src/math/trunc.c
patch
|
blob
|
history
diff --git
a/src/math/nextafter.c
b/src/math/nextafter.c
index
00209d2
..
5e53654
100644
(file)
--- a/
src/math/nextafter.c
+++ b/
src/math/nextafter.c
@@
-45,22
+45,22
@@
double nextafter(double x, double y)
if (hx >= 0) { /* x > 0 */
if (hx > hy || (hx == hy && lx > ly)) { /* x > y, x -= ulp */
if (lx == 0)
if (hx >= 0) { /* x > 0 */
if (hx > hy || (hx == hy && lx > ly)) { /* x > y, x -= ulp */
if (lx == 0)
- hx
-= 1
;
- lx
-= 1
;
+ hx
--
;
+ lx
--
;
} else { /* x < y, x += ulp */
} else { /* x < y, x += ulp */
- lx
+= 1
;
+ lx
++
;
if (lx == 0)
if (lx == 0)
- hx
+= 1
;
+ hx
++
;
}
} else { /* x < 0 */
if (hy >= 0 || hx > hy || (hx == hy && lx > ly)) { /* x < y, x -= ulp */
if (lx == 0)
}
} else { /* x < 0 */
if (hy >= 0 || hx > hy || (hx == hy && lx > ly)) { /* x < y, x -= ulp */
if (lx == 0)
- hx
-= 1
;
- lx
-= 1
;
+ hx
--
;
+ lx
--
;
} else { /* x > y, x += ulp */
} else { /* x > y, x += ulp */
- lx
+= 1
;
+ lx
++
;
if (lx == 0)
if (lx == 0)
- hx
+= 1
;
+ hx
++
;
}
}
hy = hx & 0x7ff00000;
}
}
hy = hx & 0x7ff00000;
diff --git
a/src/math/nextafterf.c
b/src/math/nextafterf.c
index
cba2dbe
..
bdc88ca
100644
(file)
--- a/
src/math/nextafterf.c
+++ b/
src/math/nextafterf.c
@@
-40,15
+40,15
@@
float nextafterf(float x, float y)
}
if (hx >= 0) { /* x > 0 */
if (hx > hy) { /* x > y, x -= ulp */
}
if (hx >= 0) { /* x > 0 */
if (hx > hy) { /* x > y, x -= ulp */
- hx
-= 1
;
+ hx
--
;
} else { /* x < y, x += ulp */
} else { /* x < y, x += ulp */
- hx
+= 1
;
+ hx
++
;
}
} else { /* x < 0 */
if (hy >= 0 || hx > hy) { /* x < y, x -= ulp */
}
} else { /* x < 0 */
if (hy >= 0 || hx > hy) { /* x < y, x -= ulp */
- hx
-= 1
;
+ hx
--
;
} else { /* x > y, x += ulp */
} else { /* x > y, x += ulp */
- hx
+= 1
;
+ hx
++
;
}
}
hy = hx & 0x7f800000;
}
}
hy = hx & 0x7f800000;
diff --git
a/src/math/nextafterl.c
b/src/math/nextafterl.c
index
1c6d537
..
aec8ab4
100644
(file)
--- a/
src/math/nextafterl.c
+++ b/
src/math/nextafterl.c
@@
-51,16
+51,16
@@
long double nextafterl(long double x, long double y)
if(x > 0.0 ^ x < y) { /* x -= ulp */
if (ux.bits.manl == 0) {
if ((ux.bits.manh&~LDBL_NBIT) == 0)
if(x > 0.0 ^ x < y) { /* x -= ulp */
if (ux.bits.manl == 0) {
if ((ux.bits.manh&~LDBL_NBIT) == 0)
- ux.bits.exp
-= 1
;
+ ux.bits.exp
--
;
ux.bits.manh = (ux.bits.manh - 1) | (ux.bits.manh & LDBL_NBIT);
}
ux.bits.manh = (ux.bits.manh - 1) | (ux.bits.manh & LDBL_NBIT);
}
- ux.bits.manl
-= 1
;
+ ux.bits.manl
--
;
} else { /* x += ulp */
} else { /* x += ulp */
- ux.bits.manl
+= 1
;
+ ux.bits.manl
++
;
if (ux.bits.manl == 0) {
ux.bits.manh = (ux.bits.manh + 1) | (ux.bits.manh & LDBL_NBIT);
if ((ux.bits.manh&~LDBL_NBIT)==0)
if (ux.bits.manl == 0) {
ux.bits.manh = (ux.bits.manh + 1) | (ux.bits.manh & LDBL_NBIT);
if ((ux.bits.manh&~LDBL_NBIT)==0)
- ux.bits.exp
+= 1
;
+ ux.bits.exp
++
;
}
}
if (ux.bits.exp == 0x7fff) /* overflow */
}
}
if (ux.bits.exp == 0x7fff) /* overflow */
diff --git
a/src/math/nexttowardf.c
b/src/math/nexttowardf.c
index
5e1616a
..
c52ef3a
100644
(file)
--- a/
src/math/nexttowardf.c
+++ b/
src/math/nexttowardf.c
@@
-42,9
+42,9
@@
float nexttowardf(float x, long double y)
return x;
}
if (hx >= 0 ^ x < y) /* x -= ulp */
return x;
}
if (hx >= 0 ^ x < y) /* x -= ulp */
- hx
-= 1
;
+ hx
--
;
else /* x += ulp */
else /* x += ulp */
- hx
+= 1
;
+ hx
++
;
ix = hx & 0x7f800000;
if (ix >= 0x7f800000) /* overflow */
return x+x;
ix = hx & 0x7f800000;
if (ix >= 0x7f800000) /* overflow */
return x+x;
diff --git
a/src/math/powl.c
b/src/math/powl.c
index
c829c18
..
0f0d894
100644
(file)
--- a/
src/math/powl.c
+++ b/
src/math/powl.c
@@
-207,7
+207,7
@@
long double powl(long double x, long double y)
if (y == 1.0L)
return x;
if (y == 1.0L)
return x;
- // FIXME: this is wrong, see pow special cases in
posix2008
+ // FIXME: this is wrong, see pow special cases in
c99 F.9.4.4
if (!isfinite(y) && (x == -1.0L || x == 1.0L) )
return y - y; /* +-1**inf is NaN */
if (x == 1.0L)
if (!isfinite(y) && (x == -1.0L || x == 1.0L) )
return y - y; /* +-1**inf is NaN */
if (x == 1.0L)
diff --git
a/src/math/remainder.c
b/src/math/remainder.c
index
c9b1b2b
..
db176c8
100644
(file)
--- a/
src/math/remainder.c
+++ b/
src/math/remainder.c
@@
-39,6
+39,7
@@
double remainder(double x, double p)
return (x*p)/(x*p);
if (hx >= 0x7ff00000 || /* x not finite */
(hp >= 0x7ff00000 && (hp-0x7ff00000 | lp) != 0)) /* p is NaN */
return (x*p)/(x*p);
if (hx >= 0x7ff00000 || /* x not finite */
(hp >= 0x7ff00000 && (hp-0x7ff00000 | lp) != 0)) /* p is NaN */
+ // FIXME: why long double?
return ((long double)x*p)/((long double)x*p);
if (hp <= 0x7fdfffff)
return ((long double)x*p)/((long double)x*p);
if (hp <= 0x7fdfffff)
diff --git
a/src/math/remainderf.c
b/src/math/remainderf.c
index
30875db
..
c17bb4f
100644
(file)
--- a/
src/math/remainderf.c
+++ b/
src/math/remainderf.c
@@
-33,6
+33,7
@@
float remainderf(float x, float p)
if (hp == 0) /* p = 0 */
return (x*p)/(x*p);
if (hx >= 0x7f800000 || hp > 0x7f800000) /* x not finite, p is NaN */
if (hp == 0) /* p = 0 */
return (x*p)/(x*p);
if (hx >= 0x7f800000 || hp > 0x7f800000) /* x not finite, p is NaN */
+ // FIXME: why long double?
return ((long double)x*p)/((long double)x*p);
if (hp <= 0x7effffff)
return ((long double)x*p)/((long double)x*p);
if (hp <= 0x7effffff)
diff --git
a/src/math/remquo.c
b/src/math/remquo.c
index
7ef0670
..
79c9a55
100644
(file)
--- a/
src/math/remquo.c
+++ b/
src/math/remquo.c
@@
-55,9
+55,9
@@
double remquo(double x, double y, int *quo)
/* determine ix = ilogb(x) */
if (hx < 0x00100000) { /* subnormal x */
if (hx == 0) {
/* determine ix = ilogb(x) */
if (hx < 0x00100000) { /* subnormal x */
if (hx == 0) {
- for (ix = -1043, i=lx; i>0; i<<=1) ix
-=1
;
+ for (ix = -1043, i=lx; i>0; i<<=1) ix
--
;
} else {
} else {
- for (ix = -1022, i=hx<<11; i>0; i<<=1) ix
-=1
;
+ for (ix = -1022, i=hx<<11; i>0; i<<=1) ix
--
;
}
} else
ix = (hx>>20) - 1023;
}
} else
ix = (hx>>20) - 1023;
@@
-65,9
+65,9
@@
double remquo(double x, double y, int *quo)
/* determine iy = ilogb(y) */
if (hy < 0x00100000) { /* subnormal y */
if (hy == 0) {
/* determine iy = ilogb(y) */
if (hy < 0x00100000) { /* subnormal y */
if (hy == 0) {
- for (iy = -1043, i=ly; i>0; i<<=1) iy
-=1
;
+ for (iy = -1043, i=ly; i>0; i<<=1) iy
--
;
} else {
} else {
- for (iy = -1022, i=hy<<11; i>0; i<<=1) iy
-=1
;
+ for (iy = -1022, i=hy<<11; i>0; i<<=1) iy
--
;
}
} else
iy = (hy>>20) - 1023;
}
} else
iy = (hy>>20) - 1023;
@@
-134,7
+134,7
@@
double remquo(double x, double y, int *quo)
while (hx < 0x00100000) { /* normalize x */
hx = hx + hx + (lx>>31);
lx = lx + lx;
while (hx < 0x00100000) { /* normalize x */
hx = hx + hx + (lx>>31);
lx = lx + lx;
- iy
-= 1
;
+ iy
--
;
}
if (iy >= -1022) { /* normalize output */
hx = (hx-0x00100000)|((iy+1023)<<20);
}
if (iy >= -1022) { /* normalize output */
hx = (hx-0x00100000)|((iy+1023)<<20);
@@
-157,11
+157,11
@@
fixup:
if (y < 0x1p-1021) {
if (x + x > y || (x + x == y && (q & 1))) {
q++;
if (y < 0x1p-1021) {
if (x + x > y || (x + x == y && (q & 1))) {
q++;
- x
-=
y;
+ x
-=
y;
}
} else if (x > 0.5*y || (x == 0.5*y && (q & 1))) {
q++;
}
} else if (x > 0.5*y || (x == 0.5*y && (q & 1))) {
q++;
- x
-=
y;
+ x
-=
y;
}
GET_HIGH_WORD(hx, x);
SET_HIGH_WORD(x, hx ^ sx);
}
GET_HIGH_WORD(hx, x);
SET_HIGH_WORD(x, hx ^ sx);
diff --git
a/src/math/remquof.c
b/src/math/remquof.c
index
beff3c5
..
11569ce
100644
(file)
--- a/
src/math/remquof.c
+++ b/
src/math/remquof.c
@@
-47,13
+47,13
@@
float remquof(float x, float y, int *quo)
/* determine ix = ilogb(x) */
if (hx < 0x00800000) { /* subnormal x */
/* determine ix = ilogb(x) */
if (hx < 0x00800000) { /* subnormal x */
- for (ix = -126, i=hx<<8; i>0; i<<=1) ix
-=1
;
+ for (ix = -126, i=hx<<8; i>0; i<<=1) ix
--
;
} else
ix = (hx>>23) - 127;
/* determine iy = ilogb(y) */
if (hy < 0x00800000) { /* subnormal y */
} else
ix = (hx>>23) - 127;
/* determine iy = ilogb(y) */
if (hy < 0x00800000) { /* subnormal y */
- for (iy = -126, i=hy<<8; i>0; i<<=1) iy
-=1
;
+ for (iy = -126, i=hy<<8; i>0; i<<=1) iy
--
;
} else
iy = (hy>>23) - 127;
} else
iy = (hy>>23) - 127;
@@
-97,7
+97,7
@@
float remquof(float x, float y, int *quo)
}
while (hx < 0x00800000) { /* normalize x */
hx <<= 1;
}
while (hx < 0x00800000) { /* normalize x */
hx <<= 1;
- iy
-= 1
;
+ iy
--
;
}
if (iy >= -126) { /* normalize output */
hx = (hx-0x00800000)|((iy+127)<<23);
}
if (iy >= -126) { /* normalize output */
hx = (hx-0x00800000)|((iy+127)<<23);
diff --git
a/src/math/rint.c
b/src/math/rint.c
index
fa6fef3
..
775c7b8
100644
(file)
--- a/
src/math/rint.c
+++ b/
src/math/rint.c
@@
-69,7
+69,7
@@
double rint(double x)
else if (j0 == 18)
i1 = 0x80000000;
else
else if (j0 == 18)
i1 = 0x80000000;
else
- i0 = (i0
&(~i))|((0x20000)
>>j0);
+ i0 = (i0
& ~i)|(0x20000
>>j0);
}
}
} else if (j0 > 51) {
}
}
} else if (j0 > 51) {
@@
-82,7
+82,7
@@
double rint(double x)
return x; /* x is integral */
i >>= 1;
if ((i1&i) != 0)
return x; /* x is integral */
i >>= 1;
if ((i1&i) != 0)
- i1 = (i1
&(~i))|((0x40000000)
>>(j0-20));
+ i1 = (i1
& ~i)|(0x40000000
>>(j0-20));
}
INSERT_WORDS(x, i0, i1);
STRICT_ASSIGN(double, w, TWO52[sx] + x);
}
INSERT_WORDS(x, i0, i1);
STRICT_ASSIGN(double, w, TWO52[sx] + x);
diff --git
a/src/math/scalbnl.c
b/src/math/scalbnl.c
index
5510186
..
0ed5b7f
100644
(file)
--- a/
src/math/scalbnl.c
+++ b/
src/math/scalbnl.c
@@
-38,11
+38,11
@@
long double scalbnl(long double x, int n)
if (k == 0) { /* 0 or subnormal x */
if ((u.bits.manh|u.bits.manl) == 0) /* +-0 */
return x;
if (k == 0) { /* 0 or subnormal x */
if ((u.bits.manh|u.bits.manl) == 0) /* +-0 */
return x;
- u.e *= 0x1p
+
128;
+ u.e *= 0x1p128;
k = u.bits.exp - 128;
if (n < -50000)
return tiny*x; /*underflow*/
k = u.bits.exp - 128;
if (n < -50000)
return tiny*x; /*underflow*/
-
}
+ }
if (k == 0x7fff) /* NaN or Inf */
return x + x;
k = k + n;
if (k == 0x7fff) /* NaN or Inf */
return x + x;
k = k + n;
diff --git
a/src/math/trunc.c
b/src/math/trunc.c
index
b0b80d1
..
44b04ec
100644
(file)
--- a/
src/math/trunc.c
+++ b/
src/math/trunc.c
@@
-37,7
+37,7
@@
double trunc(double x)
i1 = 0;
}
} else {
i1 = 0;
}
} else {
- i =
(0x000fffff)
>>j0;
+ i =
0x000fffff
>>j0;
if (((i0&i)|i1) == 0)
return x; /* x is integral */
/* raise inexact */
if (((i0&i)|i1) == 0)
return x; /* x is integral */
/* raise inexact */
@@
-51,7
+51,7
@@
double trunc(double x)
return x + x; /* inf or NaN */
return x; /* x is integral */
} else {
return x + x; /* inf or NaN */
return x; /* x is integral */
} else {
- i = (
(uint32_t)(0xffffffff))
>>(j0-20);
+ i = (
uint32_t)0xffffffff
>>(j0-20);
if ((i1&i) == 0)
return x; /* x is integral */
/* raise inexact */
if ((i1&i) == 0)
return x; /* x is integral */
/* raise inexact */