[libc-commits] [PATCH] D105153: [libc] Add on float properties for precision floating point numbers in FloatProperties.h

Hedin GarcĂ­a via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jun 30 13:33:16 PDT 2021


hedingarcia marked 6 inline comments as done.
hedingarcia added inline comments.


================
Comment at: libc/utils/FPUtil/FloatProperties.h:111
+  static constexpr BitsType mantissaMask =
+      (BitsType(0x0000ffffffffffffULL) << 64) | BitsType(0xffffffffffffffffULL);
+  static constexpr BitsType signMask = BitsType(0x8000000000000000U) << 64;
----------------
aeubanks wrote:
> `(BitsType(1) << mantissaWidth) - 1` is cleaner (and same for the other ones above)
Understood, I agree that it maintains a polished code instead of writing the long hexadecimal values.


================
Comment at: libc/utils/FPUtil/FloatProperties.h:102
+  static constexpr BitsType signMask = (BitsType)0x00008000U << 64;
+  static constexpr BitsType exponentMask = ~(signMask | mantissaMask);
+  static constexpr uint32_t exponentOffset = 16383;
----------------
lntue wrote:
> Will this mask also get garbage padding bits above 80 bits?  If it is the case then you might need to get the exact constant, something like signMask - BitType(1) - mantissaMask
Thank you for the observation, I missed that detail where the bit operations were not considering those extra bits that were used for padding. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105153



More information about the libc-commits mailing list