[libc-commits] [PATCH] D123154: [libc] Implement sinf function that is correctly rounded to all rounding modes.
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Jul 21 06:32:00 PDT 2022
lntue added inline comments.
================
Comment at: libc/src/math/generic/range_reduction.h:33-40
+static constexpr double ONE_OVER_PI_28[N_ENTRIES] = {
+ 0x1.45f306ep-2, -0x1.b1bbeaep-33, 0x1.3f84ebp-62, -0x1.7056592p-92,
+ 0x1.c0db62ap-121, -0x1.4cd8778p-150, -0x1.bef806cp-179, 0x1.63abdecp-209};
+
+// Exponents of the least significant bits of the corresponding entries in
+// ONE_OVER_PI_28.
+static constexpr int ONE_OVER_PI_28_LSB_EXP[N_ENTRIES] = {
----------------
santoshn wrote:
> I was reviewing this code. I am not able to understand how ONE_OVER_PI_28_LSB_EXP[2] == -86. The third entry in ONE_OVER_PI_28 (i.e., 0x1.3f84ebp-62) has an exponent of -62 and there are 27 fraction bits. So the exponent of the LSB should be -89.
>
> Similarly ONE_OVER_PI_28_LSB_EXP[5] is -167?
>
> Similarly ONE_OVER_PI_28_LSB_EXP[6] is -206?
>
> Similarly ONE_OVER_PI_28_LSB_EXP[7] is -236?
I think for `ONE_OVER_PI_28_LSB_EXP[2]` I over-counted a bit. The exact value `0x1.3f84eb p-62` actually has the last 1 bit at 24th bit after the decimal point (bits 25-27 are all 0's), so the correct value of `ONE_VER_PI_28_LSB_EXP[2]` should be `-62 - 24 = -66`. Similarly for other values.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123154/new/
https://reviews.llvm.org/D123154
More information about the libc-commits
mailing list