[libc-commits] [PATCH] D110643: [libc] Add support for 128 bit ints in limits.h

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Sep 28 15:08:34 PDT 2021


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


================
Comment at: libc/utils/CPP/Limits.h:63
+//   static constexpr __int128_t max() {
+//     return -(~__int128_t(0) + 1);
+//   }
----------------
sivachandra wrote:
> michaelrj wrote:
> > sivachandra wrote:
> > > May be just `~__uint128_t(0) - 1`?
> > That doesn't work as int max, since it comes out to `0xfffffffffffffffffffffffffffffffe`, as opposed to the `0x7fffffffffffffffffffffffffffffff`. I've changed it to be the most logical way I can think of that doesn't rely on overflow/underflow.
> Uh, sorry! Not sure why I put a `-` instead of a `>>`. I wanted to say this:
> 
> ```
>   return ~__uint128_t(0) >> 1;
> ```
ah, yes that does work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110643



More information about the libc-commits mailing list