about summary refs log tree commit diff
path: root/sysdeps/ieee754/ldbl-96/s_lroundl.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix lround, llround missing exceptions close to overflow threshold (bug 19088).Joseph Myers2015-10-071-3/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The dbl-64, ldbl-96 and ldbl-128 implementations of lround and llround fail to produce "invalid" exceptions in cases where the rounded result overflows the target type, but truncating the floating-point argument to the next integer towards zero does not overflow it (so in particular casts do not produce such exceptions). (This issue cannot arise for float, or for double with 64-bit target type, or for ldbl-96 with 64-bit target type and negative arguments, because of insufficient precision in the floating-point type for arguments with the relevant property to exist.) This patch fixes these problems by inserting checks for the special cases that can occur in each implementation, and explicitly raising FE_INVALID (and avoiding the cast if it might raise spurious FE_INEXACT). Tested for x86_64, x86 and mips64. [BZ #19088] * sysdeps/ieee754/dbl-64/s_lround.c: Include <fenv.h> and <limits.h>. (__lround) [FE_INVALID]: Force FE_INVALID exception when result overflows but exception would not result from cast. * sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Include <fenv.h> and <limits.h>. (__lround) [FE_INVALID]: Force FE_INVALID exception when result overflows but exception would not result from cast. * sysdeps/ieee754/ldbl-128/s_llroundl.c: Include <fenv.h> and <limits.h>. (__llroundl) [FE_INVALID]: Force FE_INVALID exception when result overflows but exception would not result from cast. * sysdeps/ieee754/ldbl-128/s_lroundl.c: Include <fenv.h> and <limits.h>. (__lroundl) [FE_INVALID]: Force FE_INVALID exception when result overflows but exception would not result from cast. * sysdeps/ieee754/ldbl-96/s_llroundl.c: Include <fenv.h> and <limits.h>. (__llroundl) [FE_INVALID]: Force FE_INVALID exception when result overflows but exception would not result from cast. * sysdeps/ieee754/ldbl-96/s_lroundl.c: Include <fenv.h> and <limits.h>. (__lroundl) [FE_INVALID]: Force FE_INVALID exception when result overflows but exception would not result from cast. * math/libm-test.inc (lround_test_data): Add more tests. (llround_test_data): Likewise.
* Fix ldbl-96 lroundl just below powers of 2 (bug 19071).Joseph Myers2015-10-051-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ldbl-96 version of lroundl is incorrect for systems with 64-bit long when the argument's absolute value is just below a power of 2, 2^32 or more, and rounds up to the next integer; in such cases, it returns 0. The problem is incrementing the high part of the mantissa loses the high bit of the value (which is not an issue for any other floating-point format, and is handled specially in lround when the bit corresponding to 0.5 was in the high part rather than the low part). This patch fixes this in a similar way to that used in llroundl: storing the high part in an unsigned long variable before incrementing it, so problems cannot occur in the case when this code is reachable. I improved test coverage for both lround and llround by making them use the same test inputs (appropriately conditioned on the size of long in the lround case) - complete with the same comments, to make comparison as easy as possible. (This test coverage improvement was how I found the lroundl bug.) Tested for x86_64 and x86. [BZ #19071] * sysdeps/ieee754/ldbl-96/s_lroundl.c (__lroundl): Use unsigned long int variable to store possibly incremented high part of mantissa. * math/libm-test.inc (lround_test_data): Add tests used for llround. Use [LONG_MAX > 0x7fffffff] consistently as condition for tests requiring 64-bit long. Do not condition tests on [TEST_FLOAT] unnecessarily. (llround_test_data): Add tests used for lround. Add another expectation for the "inexact" exception. Do not condition tests on [TEST_FLOAT] unnecessarily.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2015-01-021-1/+1
|
* Update copyright notices with scripts/update-copyrightsAllan McRae2014-01-011-1/+1
|
* Update copyright notices with scripts/update-copyrights.Joseph Myers2013-01-021-1/+1
|
* Use <> for math.h and math_private.h everywhere.Richard Henderson2012-03-091-1/+1
| | | | Entire tree edited via find | grep | sed.
* Replace FSF snail mail address with URLs.Paul Eggert2012-02-091-3/+2
|
* Update.Ulrich Drepper2004-02-011-2/+5
| | | | | | | | | | | | | | * math/libm-test.inc (lround_test): Add new test. (llround_test): Likewise. (lrint_test): Likewise. (llrint_test): Likewise. * sysdeps/ieee754/dbl-64/s_lround.c (__lround): Fix special case with result taking up 20 bits. * sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Likewise. * sysdeps/ieee754/dbl-64/s_llrint.c (__llrint): Likewise.. * sysdeps/ieee754/ldbl-96/s_lroundl.c (__lroundl): Fix special case with result taking up 31 bits. * sysdeps/ieee754/ldbl-96/s_lrintl.c (__lrintl): Likewise.
* Update to LGPL v2.1.Andreas Jaeger2001-07-061-8/+8
| | | | | | | | | | | | | | 2001-07-06 Paul Eggert <eggert@twinsun.com> * manual/argp.texi: Remove ignored LGPL copyright notice; it's not appropriate for documentation anyway. * manual/libc-texinfo.sh: "Library General Public License" -> "Lesser General Public License". 2001-07-06 Andreas Jaeger <aj@suse.de> * All files under GPL/LGPL version 2: Place under LGPL version 2.1.
* Update.Ulrich Drepper1999-07-141-0/+78