[libc-commits] [PATCH] D114726: [libc] Fix bugs with negative and mixed normal/denormal inputs in hypot implementation.

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Dec 1 07:48:36 PST 2021


lntue added inline comments.


================
Comment at: libc/utils/MPFRWrapper/MPFRUtils.cpp:315-318
+    if (fputil::FPBits<T>(thisAsT).getUnbiasedExponent() == 0)
+      ++thisExponent;
+    if (fputil::FPBits<T>(input).getUnbiasedExponent() == 0)
+      ++inputExponent;
----------------
michaelrj wrote:
> based on my testing, the tests still pass if you don't update this file, could you add something to explain these changes, and possibly split them off into their own patch?
This is because without this change, the ULPs are computed off by a factor of 2^(-mantissaWidth), and hence all the tests still pass.  As in the comments in line 287-294, the factor that we divide is eps(...) which should be 2^(exponent - mantissaWidth) for normal numbers, and 2^(1 - exponentBias - mantissaWidth) for denormal numbers. 

With changes in this file, updated HypotTests without the fix in Hypot.h shall fail.  In any case, I split the change in the ULP function to https://reviews.llvm.org/D114726


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114726



More information about the libc-commits mailing list