Menu

BI

Richard

The BI class is the Big Integer class. It can handle any size of integer. The number is held in a managed array of size unsigned int if compiling to 32 bit and unsigned __int64 if compiling to 64 bit. The sign of the instance is held in an instance of the Sign enumeration with Negative=-1 NA=0 and Positive=1. The class has all of the implicit and explicit operators overloaded so that you can do math with all of the standard types in c++.

The class has the +, +=, -, -=, , =, /, /=, %, %= operators plus Pow, ModPow, LCD, GCD algorithms all of which return a new instance of the BI class.

The IsPrime(int _security) algorithm uses an instance of Miller Rabbin probablistic primality test, which is usually good enough if you set the _security high enough (in practice I usually use a value of 20, Im not sure how many non-primes get through that way, but it works).

All of the basic math stuff is done in assembly language, through static calls in the [Base].h/Base.cpp files. This involves setting up static pointers for the arrays being passed in, and recieves an MYWORDPTR as a return value, which is converted to a managed array. This is all done internally and should be transparent to the user.


Related

Wiki: Home

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.