allow omitted inexact in nearest integer functions
authorSzabolcs Nagy <nsz@port70.net>
Sun, 25 Aug 2019 18:27:16 +0000 (18:27 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Sat, 7 Sep 2019 15:37:23 +0000 (15:37 +0000)
in ceil, floor, trunc, round, lround and llround omitting inexact
is not an error (in fact it will be required to be omitted in c2x,
but c11 allows both behaviours).

18 files changed:
src/math/ceil.c
src/math/ceilf.c
src/math/ceill.c
src/math/floor.c
src/math/floorf.c
src/math/floorl.c
src/math/llround.c
src/math/llroundf.c
src/math/llroundl.c
src/math/lround.c
src/math/lroundf.c
src/math/lroundl.c
src/math/round.c
src/math/roundf.c
src/math/roundl.c
src/math/trunc.c
src/math/truncf.c
src/math/truncl.c

index 253654c..8fe2bf9 100644 (file)
@@ -27,7 +27,7 @@ int main(void)
                y = ceil(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s ceil(%a)=%a, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index 3d20997..e3c3538 100644 (file)
@@ -27,7 +27,7 @@ int main(void)
                y = ceilf(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s ceilf(%a)=%a, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index 2674c56..45d24a1 100644 (file)
@@ -33,7 +33,7 @@ int main(void)
                y = ceill(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s ceill(%La)=%La, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index ca715dc..267dabd 100644 (file)
@@ -27,7 +27,7 @@ int main(void)
                y = floor(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s floor(%a)=%a, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index ca3bf0c..09039df 100644 (file)
@@ -27,7 +27,7 @@ int main(void)
                y = floorf(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s floorf(%a)=%a, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index 644724e..3e3d397 100644 (file)
@@ -33,7 +33,7 @@ int main(void)
                y = floorl(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s floorl(%La)=%La, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index a6c991a..535611a 100644 (file)
@@ -25,7 +25,7 @@ int main(void)
                yi = llround(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexcept(e, p->e, p->r)) {
+               if (!checkexcept(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s llround(%a)=%lld, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
                        printf(" got %s\n", estr(e));
index 0a61cf9..0303099 100644 (file)
@@ -25,7 +25,7 @@ int main(void)
                yi = llroundf(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexcept(e, p->e, p->r)) {
+               if (!checkexcept(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s llroundf(%a)=%lld, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
                        printf(" got %s\n", estr(e));
index 5025b16..de46e7e 100644 (file)
@@ -31,7 +31,7 @@ int main(void)
                yi = llroundl(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexcept(e, p->e, p->r)) {
+               if (!checkexcept(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s llroundl(%La)=%lld, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
                        printf(" got %s\n", estr(e));
index f1ac491..92835b1 100644 (file)
@@ -25,7 +25,7 @@ int main(void)
                yi = lround(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexcept(e, p->e, p->r)) {
+               if (!checkexcept(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s lround(%a)=%lld, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
                        printf(" got %s\n", estr(e));
index c954482..303cb6a 100644 (file)
@@ -25,7 +25,7 @@ int main(void)
                yi = lroundf(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexcept(e, p->e, p->r)) {
+               if (!checkexcept(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s lroundf(%a)=%lld, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
                        printf(" got %s\n", estr(e));
index 42b8479..0b933be 100644 (file)
@@ -31,7 +31,7 @@ int main(void)
                yi = lroundl(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexcept(e, p->e, p->r)) {
+               if (!checkexcept(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s lroundl(%La)=%lld, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
                        printf(" got %s\n", estr(e));
index c7b8766..495ad1d 100644 (file)
@@ -26,7 +26,7 @@ int main(void)
                y = round(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s round(%a)=%a, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index d61762f..5a8f2e5 100644 (file)
@@ -26,7 +26,7 @@ int main(void)
                y = roundf(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s roundf(%a)=%a, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index 53eda20..a121472 100644 (file)
@@ -32,7 +32,7 @@ int main(void)
                y = roundl(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s roundl(%La)=%La, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index 377118c..e861947 100644 (file)
@@ -26,7 +26,7 @@ int main(void)
                y = trunc(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s trunc(%a)=%a, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index 94825d9..657f2fc 100644 (file)
@@ -26,7 +26,7 @@ int main(void)
                y = truncf(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s truncf(%a)=%a, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));
index 98d5197..f0e8f0c 100644 (file)
@@ -32,7 +32,7 @@ int main(void)
                y = truncl(p->x);
                e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
 
-               if (!checkexceptall(e, p->e, p->r)) {
+               if (!checkexceptall(e, p->e, p->r) && (e|INEXACT) != p->e) {
                        printf("%s:%d: bad fp exception: %s truncl(%La)=%La, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
                        printf(" got %s\n", estr(e));