From: Szabolcs Nagy Date: Sun, 25 Aug 2019 18:27:16 +0000 (+0000) Subject: allow omitted inexact in nearest integer functions X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=commitdiff_plain;h=b55b931794bff9e88a3443daa8404c74f7f1d17c allow omitted inexact in nearest integer functions 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). --- diff --git a/src/math/ceil.c b/src/math/ceil.c index 253654c..8fe2bf9 100644 --- a/src/math/ceil.c +++ b/src/math/ceil.c @@ -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)); diff --git a/src/math/ceilf.c b/src/math/ceilf.c index 3d20997..e3c3538 100644 --- a/src/math/ceilf.c +++ b/src/math/ceilf.c @@ -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)); diff --git a/src/math/ceill.c b/src/math/ceill.c index 2674c56..45d24a1 100644 --- a/src/math/ceill.c +++ b/src/math/ceill.c @@ -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)); diff --git a/src/math/floor.c b/src/math/floor.c index ca715dc..267dabd 100644 --- a/src/math/floor.c +++ b/src/math/floor.c @@ -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)); diff --git a/src/math/floorf.c b/src/math/floorf.c index ca3bf0c..09039df 100644 --- a/src/math/floorf.c +++ b/src/math/floorf.c @@ -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)); diff --git a/src/math/floorl.c b/src/math/floorl.c index 644724e..3e3d397 100644 --- a/src/math/floorl.c +++ b/src/math/floorl.c @@ -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)); diff --git a/src/math/llround.c b/src/math/llround.c index a6c991a..535611a 100644 --- a/src/math/llround.c +++ b/src/math/llround.c @@ -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)); diff --git a/src/math/llroundf.c b/src/math/llroundf.c index 0a61cf9..0303099 100644 --- a/src/math/llroundf.c +++ b/src/math/llroundf.c @@ -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)); diff --git a/src/math/llroundl.c b/src/math/llroundl.c index 5025b16..de46e7e 100644 --- a/src/math/llroundl.c +++ b/src/math/llroundl.c @@ -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)); diff --git a/src/math/lround.c b/src/math/lround.c index f1ac491..92835b1 100644 --- a/src/math/lround.c +++ b/src/math/lround.c @@ -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)); diff --git a/src/math/lroundf.c b/src/math/lroundf.c index c954482..303cb6a 100644 --- a/src/math/lroundf.c +++ b/src/math/lroundf.c @@ -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)); diff --git a/src/math/lroundl.c b/src/math/lroundl.c index 42b8479..0b933be 100644 --- a/src/math/lroundl.c +++ b/src/math/lroundl.c @@ -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)); diff --git a/src/math/round.c b/src/math/round.c index c7b8766..495ad1d 100644 --- a/src/math/round.c +++ b/src/math/round.c @@ -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)); diff --git a/src/math/roundf.c b/src/math/roundf.c index d61762f..5a8f2e5 100644 --- a/src/math/roundf.c +++ b/src/math/roundf.c @@ -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)); diff --git a/src/math/roundl.c b/src/math/roundl.c index 53eda20..a121472 100644 --- a/src/math/roundl.c +++ b/src/math/roundl.c @@ -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)); diff --git a/src/math/trunc.c b/src/math/trunc.c index 377118c..e861947 100644 --- a/src/math/trunc.c +++ b/src/math/trunc.c @@ -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)); diff --git a/src/math/truncf.c b/src/math/truncf.c index 94825d9..657f2fc 100644 --- a/src/math/truncf.c +++ b/src/math/truncf.c @@ -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)); diff --git a/src/math/truncl.c b/src/math/truncl.c index 98d5197..f0e8f0c 100644 --- a/src/math/truncl.c +++ b/src/math/truncl.c @@ -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));