Date: Tue, 24 Jul 2018 07:41:17 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Steve Kargl <sgk@troutmask.apl.washington.edu> Cc: enh via freebsd-numerics <freebsd-numerics@freebsd.org> Subject: Re: fmod nan_mix usage Message-ID: <20180724071036.O868@besplex.bde.org> In-Reply-To: <20180723193418.GA66380@troutmask.apl.washington.edu> References: <CAJgzZopb_0fxM9jbVjUEZ0JPOfcrgeQo_Ki-afZ5aRNr38tKVg@mail.gmail.com> <20180723193418.GA66380@troutmask.apl.washington.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 23 Jul 2018, Steve Kargl wrote: > On Mon, Jul 23, 2018 at 11:28:08AM -0700, enh via freebsd-numerics wrote: >> the recent change from >> >> return (x*y)/(x*y); >> >> to >> >> return nan_mix(x, y)/nan_mix(x, y); >> >> in e_fmod.c broke some of our unit tests. for example, fmod(3.f, 0.f) in >> one of the VM tests. >> >> bionic/tests/math_test.cpp:(784) Failure in test >> math_h_force_long_double.fmod >> Value of: isnan(fmod(3.0, 0.0)) >> Actual: false >> Expected: true > > Can you share the code for the relevant tests? > This simple program gives the expected results > on amd64. > > #include <math.h> > #include <stdio.h> > > int > main(void) > { > printf("%e %d\n", fmodf(3.f, 0.f), isnan(fmodf(3.f, 0.f))); > printf("%le %d\n", fmod(3.0, 0.0), isnan(fmod(3.0, 0.0))); > printf("%Le %d\n", fmodl(3.L, 0.L), isnan(fmodl(3.L, 0.L))); > return 0; > } > > % cc -o z -O a.c -lm && ./z > nan 1 > nan 1 > nan 1 clang normally evaluates this at compile, so it doesn't test the libary. This is arguably a bug in clang, since it doesn't set the exception flags. #pragma FENV_ACCESS should control this, but it is hard to use and rarely works. The test data needs to be non-literal and perhaps even volatile to prevent the compiler evaluating it at compile time. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180724071036.O868>