[libc-commits] [PATCH] D94109: [libc] Add implementations of nextafter[f|l] functions.

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jan 5 16:00:50 PST 2021


lntue added inline comments.


================
Comment at: libc/utils/FPUtil/ManipulationFunctions.h:162-177
+  if (from < T(0.0)) {
+    if (from > to)
+      ++intVal;
+    else
+      --intVal;
+  } else if (from == T(0.0)) {
+    if (from > to)
----------------
We can reduce the if-else chain a bit as follows:
  if (from != T(0.0)) {
    if ((from < to) == (from > T(0.0)) {
      ++intVal;
    } else {
      --intVal;
    }
  } else {
    intVal = (to.bitsAsUInt() & signMask) + UIntType(1);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94109



More information about the libc-commits mailing list