[libc-commits] [PATCH] D127046: [libc][math] fmod/fmodf implementation.

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jun 23 10:24:04 PDT 2022


lntue added inline comments.


================
Comment at: libc/src/__support/FPUtil/generic/FMod.h:81
+
+    if (unlikely(fputil::isnan(x) || fputil::isnan(y))) {
+      out = fputil::quiet_NaN(T(0));
----------------
orex wrote:
> lntue wrote:
> > From the C standard, `fmod(0, NaN)` and `fmod(0, inf)` should be `0`
> > ```
> > If x is ±0 and y is not zero, ±0 is returned
> > ```
> Thank you. This is a very good comment. Obviously C standard "F.10.7.1" is not full. It do not describe at all, for example, NaN NaN case. I also do not think, that fmod(0, NaN) should return zero. I prefer to go for better consistent standard which are described here
> https://pubs.opengroup.org/onlinepubs/9699919799/functions/fmod.html
> https://en.cppreference.com/w/c/numeric/math/fmod
> What do you think about this?
I agree that this makes more sense.  We should add a link to `https://man7.org/linux/man-pages/man3/fmod.3p.html` to support our decision, and maybe send suggestion to `cppreference` to adjust the order of exceptional cases on their page.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127046/new/

https://reviews.llvm.org/D127046



More information about the libc-commits mailing list