In Russian   IMach   Priest - portal of dialogue and creativity   Author  

   E-mail  Last modified - Aug 3, 2024

C++ class for integers of unlimited range

C++ class  cBigNumber  implements integers of unlimited range with excellent performance and trustworthiness.
The class provides for all regular operations of language C++, including arithmetic, logic and bitwise operations, operations of comparison, shift operations, and also stream input-output with all of integer modifiers. Extra functions - power, power by module, square root and Miller strong probable primality test.
The class uses fast algorithms, such as the binary exponentiation, optimized for numbers containing up to 100,000 and more bits. More large numbers can also be used; the exponentiation tests were carried out for numbers containing up to 12,000,000 bits.

The class has reenterable code to support development of multithreaded applications.
Test environments: Microsoft Visual C++ 6.0, 2002-2022, Borland C++ 3.1 (16 bit), 4.5, Builder 1.0, GNU g++ 2.9.6, 3.3.3 (ARM), 4.1.2, 4.2.3, 6.4.0, 9.4.0, Clang++ 4.0.0, 10.0.0.
Performance of the classnew
The programmer's manual and change listnew

Test:
Download:
History:
 
 
Preceding
versions:
Version 2.2 beta public of Aug 3, 2024new (10 more times faster division and binary exponentiation)
Version 2.1c public update of Oct 29, 2023 (C++ 11 and clang compatibility)
Version 2.1c public of Nov 17, 2017, documentation updated Oct 23, 2022 (optimized division by 64/128 bit divider)
Version 2.1b beta public of Sep 10, 2017, documentation updated Nov 10, 2017 (optimized division by 64/128 bit divider)
Version 2.1a beta public of Jun 27, 2017 (optimized division by 32/64 bit divider)
Version 2.1 beta public of Dec 28, 2016 (fast intrinsic-based multiplication and operations with 64 bit divider/module)
Version 2.0a public of Jul 29, 2016 (asm code with MULX instruction)
Version 2.0 public of Nov 20, 2010, documentation updated Jan 16, 2015 (64 bit C/asm code for Visual C++/g++)
32-bit versions:  1.2c public of Mar 30, 2011 (reenterable)  1.2b public of Nov 19, 2009, updated Nov 20, 2010 (g++)
32-bit beta beta versions:  1.2a beta public of Sep 22, 2007  1.2 beta public of Jun 15, 2007  1.1a beta public of Nov 26, 2005
Assembler add-on for Visual/Borland C++ and g++ with faster multiplication and division is available by request.
Donations: You must not pay for class cBigNumber. If you have decided to support its development - contact me. Amount is for choice of your own. The transfer is accepted as voluntary donation, funds of which are directed to development and testing of the class. Donation may be conditioned by implementation of additional functions by agreement.
Forum: Consultations (rus)
Contacts:
  • To subscribe to the mailing list 
  • click here and send message.
  • To cancel mailing subscription 
  • click here and send message.
  • To write a letter to the author 
  • click here.
    Though it is not required, you are strongly encouraged to subscribe to the mailing list. The mailing list is intended for delivering of announcements concerning new versions of this software and bug warnings. The author confirms that your email address will never be used for any other purposes and will not be delivered to third persons.

    Publications:
    Paper for Programming and Computer Software 1/2010 (rus)   English translation, ShpringerLink   doi:10.1134/S0361768810010068
    Paper for Program Products and Systems 1/2009 (rus)   DOC file  
    Paper for SIBERCRYPT'05 (rus)   DOC file   Abstract (eng)   DOC file (eng)  

    Links:  C++ template of dynamic arrays with automatic check of an index
    Big Natural Numbers (rus)   The Prime Page   Miller strong probable prime test