[libc-commits] [PATCH] D127097: [libc][math] Improved FBits performance and readablity.

Kirill Okhotnikov via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jun 7 01:44:34 PDT 2022


orex marked an inline comment as done.
orex added inline comments.


================
Comment at: libc/src/__support/FPUtil/FloatProperties.h:49
 
-  static constexpr uint32_t BIT_WIDTH = sizeof(BitsType) << 3;
+  static constexpr uint32_t BIT_WIDTH = sizeof(BitsType) * 8;
 
----------------
sivachandra wrote:
> Why is multiplication by 8 preferred over shift by 3?
Just to improve readability. Everybody knows, that byte has 8 bits. But in previous representation it should:
1) Understand that `<< ` refers to explicit multiplication, but not bit/masks operations as everywhere else in the code.
2) Remember that 2^3=8.
Of course, it is not a big problem, but the code is still complex and need attention. And we should not add extra complications for nothing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127097



More information about the libc-commits mailing list