diff options
| author | Bruce Evans <bde@FreeBSD.org> | 2005-12-03 07:23:30 +0000 |
|---|---|---|
| committer | Bruce Evans <bde@FreeBSD.org> | 2005-12-03 07:23:30 +0000 |
| commit | 7441377544253f2735d8aff17e43e2cd64826b41 (patch) | |
| tree | 6932d97bc842cacc9230853c8362c0f3d677d31d /lib/msun | |
| parent | c26efd485e5809ab7339e8844d9b93db4f94f324 (diff) | |
Notes
Diffstat (limited to 'lib/msun')
| -rw-r--r-- | lib/msun/src/s_rint.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/msun/src/s_rint.c b/lib/msun/src/s_rint.c index 9a2b42e96e99..2d9b672be07f 100644 --- a/lib/msun/src/s_rint.c +++ b/lib/msun/src/s_rint.c @@ -65,7 +65,16 @@ rint(double x) if(((i0&i)|i1)==0) return x; /* x is integral */ i>>=1; if(((i0&i)|i1)!=0) { + /* + * Some bit is set after the 0.5 bit. To avoid the + * possibility of errors from double rounding in + * w = TWO52[sx]+x, adjust the 0.25 bit to a lower + * guard bit. We do this for all j0<=51. The + * adjustment is trickiest for j0==18 and j0==19 + * since then it spans the word boundary. + */ if(j0==19) i1 = 0x40000000; else + if(j0==18) i1 = 0x80000000; else i0 = (i0&(~i))|((0x20000)>>j0); } } |
