[libc-commits] [PATCH] D136799: [libc] Implement a high-precision floating point class.
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Dec 13 09:13:14 PST 2022
lntue added inline comments.
================
Comment at: libc/src/__support/FPUtil/dyadic_float.h:1
+//===-- A class to store high precision floating point numbers --*- C++ -*-===//
+//
----------------
sivachandra wrote:
> Will this class be ever used from outside of the `math` directory? If no, then it probably should live in `src/math`.
I plan to use this to replace `NormalFloat` and `XFloat` classes, along with their usages in `DivisionAndRemainderOperations` or `NearestIntegerOperations`. Once the replacement completes, we will move them to `src/math` together.
================
Comment at: libc/src/__support/FPUtil/dyadic_float.h:34
+
+ template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
+ DyadicFloat(T x) {
----------------
sivachandra wrote:
> This should like have additional constraints. For example, should this allow a quad-precision number to be converted to `DyadicFloat<64>`?
Added checks for mantissa lengths.
================
Comment at: libc/src/__support/FPUtil/dyadic_float.h:73
+
+ // Assume that it is already normalized and output is also normal.
+ // Output is rounded correctly with respect to the current rounding mode.
----------------
sivachandra wrote:
> Why is this assumption required?
Added explanation.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136799/new/
https://reviews.llvm.org/D136799
More information about the libc-commits
mailing list