Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #122810

Re: Is there a current best library for large integers?

From Lynn McGuire <lynnmcguire5@gmail.com>
Newsgroups comp.lang.c++
Subject Re: Is there a current best library for large integers?
Date 2025-10-03 15:41 -0500
Organization A noiseless patient Spider
Message-ID <10bpcdm$22blb$4@dont-email.me> (permalink)
References <10beov9$383mp$1@dont-email.me> <20250930010319.00002e64@yahoo.com> <10bg05l$3gpkv$1@dont-email.me>

Show all headers | View raw


On 9/30/2025 2:17 AM, David Brown wrote:
> On 30/09/2025 00:03, Michael S wrote:
>> On Mon, 29 Sep 2025 21:08:09 +0100
>> Vir Campestris <vir.campestris@invalid.invalid> wrote:
>>
>>> I could knock something up - all I need to do is total a ****** lot
>>> of small numbers accurately, but the result is more than 64 bits.
>>>
>>> Andy
>>
>> If you neeed just a little more than 64 bit then use 128-bit integers.
>> For decades gcc and clang feature a non-standard type __int128.
> 
> Yes, that should be the easiest way - as long as the target has native 
> 64-bit support.  For 32-bit (or smaller) targets, gcc does not have 
> __int128.
> 
> A simple "Int128" class with support for basic arithmetic should be 
> quick to write, however - especially if you don't need division.
> 
>>
>> Or switch to better languge. Then you can use standard type
>> _BitInt(128). Or _BitInt(256). Or _BitInt(0x8000).
>>
>> As a general rule, C is a decent improvement on its successor and that
>> is just one example.
>>
> 
> _BitInt is likely coming to C++ too, though the details are not in place 
> yet.  I'd guess any C and C++ compiler that supports _BitInt in C23 will 
> also accept it as a non-standard extension in C++.

I use bigint in my C++ code.  I have used it for around 20 years now.

Lynn

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Is there a current best library for large integers? Vir Campestris <vir.campestris@invalid.invalid> - 2025-09-29 21:08 +0100
  Re: Is there a current best library for large integers? olcott <polcott333@gmail.com> - 2025-09-29 15:40 -0500
    Re: Is there a current best library for large integers? Bonita Montero <Bonita.Montero@gmail.com> - 2025-10-07 18:24 +0200
      Re: Is there a current best library for large integers? scott@slp53.sl.home (Scott Lurndal) - 2025-10-07 17:56 +0000
        Re: Is there a current best library for large integers? Bonita Montero <Bonita.Montero@gmail.com> - 2025-10-08 04:38 +0200
          Re: Is there a current best library for large integers? scott@slp53.sl.home (Scott Lurndal) - 2025-10-08 14:02 +0000
  Re: Is there a current best library for large integers? olcott <polcott333@gmail.com> - 2025-09-29 15:45 -0500
  Re: Is there a current best library for large integers? Barry Schwarz <schwarzb@delq.com> - 2025-09-29 14:19 -0700
  Re: Is there a current best library for large integers? Michael S <already5chosen@yahoo.com> - 2025-09-30 01:03 +0300
    Re: Is there a current best library for large integers? David Brown <david.brown@hesbynett.no> - 2025-09-30 09:17 +0200
      Re: Is there a current best library for large integers? Michael S <already5chosen@yahoo.com> - 2025-09-30 14:02 +0300
      Re: Is there a current best library for large integers? Lynn McGuire <lynnmcguire5@gmail.com> - 2025-10-03 15:41 -0500
    Re: Is there a current best library for large integers? Vir Campestris <vir.campestris@invalid.invalid> - 2025-10-03 17:05 +0100
      Re: Is there a current best library for large integers? Ralf Goertz <me@myprovider.invalid> - 2025-10-06 17:34 +0200
        Re: Is there a current best library for large integers? Paavo Helde <eesnimi@osa.pri.ee> - 2025-10-07 10:44 +0300
          Re: Is there a current best library for large integers? Ralf Goertz <me@myprovider.invalid> - 2025-10-07 10:51 +0200
  Re: Is there a current best library for large integers? Michael S <already5chosen@yahoo.com> - 2025-09-30 14:21 +0300

csiph-web