Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: How to create a 128 bit type in C Date: Tue, 28 Mar 2017 11:40:00 -0700 Organization: None to speak of Lines: 35 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="621a15f5f24560a56e85ad6532f35357"; logging-data="13986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/28hUlVIXS4SjN6eoP1Hxa" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:bESeIvDvCO5ojJuhdh0YFwGnK2k= sha1:r2giW2+1r7x9+nsiWrn8ryMh0Og= Xref: csiph.com comp.lang.c:107297 jacobnavia writes: > Le 28/03/2017 à 18:29, Scott Lurndal a écrit : >> acidlategamer@gmail.com writes: >>> Today a friend of mine asked this to me >>> create a 128 bit type and you are given two 64 bit int type. One is >>> sint64_t and one is uint64_t >>> >> >> Personally, I'd either use the GCC extension int128_t/uint128_t or >> use the gnu multiprecision library rather than reinventing the wheel. >> > > 128 bit integers are not a gcc extension. Lcc-win has that too. Then they're also an lcc-win extension. BTW, glibc's doesn't define int128_t or uint128_t. gcc predefines, *on some systems*, types `__int128` and `unsigned __int128`. There are no integer constants of those types, and intmax_t and uintmax_t are still 64 bits (which I consider unfortunate). (Apparently there are some ABI issues that prevented them from treating them as integer types and adjusting [u]intmax_t accordingly.) > But the advantage of reinventing wheels is that you learn how wheels are > done and how they work... Yes, whether it makes sense to reinvent the wheel depends very much on what your actual goal is. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"