Skip to content
/ BeeNum Public

BeeNum is an arbitrary-precision arithmetic library.

License

Notifications You must be signed in to change notification settings

tigertv/BeeNum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BeeNum

github-actions

BeeNum is an arbitrary-precision arithmetic library.

Integers:

Bint a = "372542872459";
Bint b = "-29351077";
Bint c = "-SomeNumbersAreHere::62";                // base 62
Bint d = "-9:10:79:100:16:3:35:72:76:15:11::101";  // base 101

a *= b;

std::cout << "a = " << a << std::endl;
std::cout << "a bin = " << a.bin() << std::endl;
std::cout << "a hex = " << a.hex() << std::endl;
std::cout << "a oct = " << a.oct() << std::endl;
std::cout << "a b12 = " << a.base(12) << std::endl;
std::cout << "a b16 = " << a.base(16) << std::endl;
std::cout << "a b62 = " << a.base(62) << std::endl;
std::cout << "a b100 = " << a.base(100) << std::endl;
std::cout << "a b101 = " << a.base(101) << std::endl;
std::cout << "-a hex= " << (-a).hex() << std::endl;

a = Math::fib(2344); // fibonnaci
std::cout << "a = " << a << std::endl;
a = Math::fact(2344); // factorial
std::cout << "a = " << a << std::endl;

Output:

a = -10934534535345288343
a bin = 0b11111111111111111111111111111111111111111111111111111111111111110110100001000000101110101100011000010100100000001100101101101001
a hex = 0xffffffffffffffff6840bac61480cb69
a oct = 03777777777777777777776641005654302440145551
a b12 = -4b1864994618b07247::12
a b16 = -97bf4539eb7f3497::16
a b62 = -d1KhCnN5DsH::62
a b100 = -10:93:45:34:53:53:45:28:83:43::100
a b101 = -9:100:79:38:16:3:35:72:76:15::101
-a hex= 0x000000000000000097bf4539eb7f3497
a = 3292636163395024367203468473569524756643504121012844896096537327933868120094412497040602775152572215865563160589549803525642230638215962365456769283299059545111493596481118009871253620689741369268903929271547189925964105732185114343148279766732776564135330585999837804716970141613627707728875235226521977279570816674613873171176272739184670585253011586091130410738892672880825317801152473484664507980075569727857490445475808429292084727199544336720900623844157649066893717994088750765435083
a = 18986731798629253220671300885142313336688051876196376804540809802650384949875016046615025899503961641732182336769103319236840437449601140671345984851122721760131425534692229714763062905706733176858764135567064645253395447124350553194118836976515601454707475528418211056034505325558468514159427351101210191037468366245147748594544386889782543056511487999423544977122220805265509368951204457302756776184253126536690153653560525087929088238381804507254728800284235626611808430966867812714467440288124340104117163434977554850405794886100682302288719156275876275718371597637020180068184872749169441320994584204543773758506427693721479790800353586089617913383642335280314764406644108579303724751553233935673801543700550057589203642191894024441356820608970357620806648980451443210104281574896831860393625299107261500826172297883189703447349325084648382181401548201515803154905132260754707273822348477759858681931356514452652308138353931293765302587300137853372212059322653471731019805728188271770665929592706918489675023678472402481200169648713630855769721907614959515245031508071721734364908914158156765292622987366523323825306330006388632879942791108532222293747076165916385308540348065162099420676827494513945931036618827913395343181877720089116742614812573793441052904664214203421586759617621045410073999823507579665443942630881672450889794320463076008268044935918323157982323419097228830010253358567770813771632941826618084290764056570319108427902698367479270212888808442153805337077616641891588881995223117780326278915631362143204568789060785049480302006513861524845865088567485529441181010835855979328158749166377381431970695779575358333029908777416422251888072656444310371548375646187903056536200775538667593845640688159776624307179042155770501955596507112208925877418647661698909089334513601260764744079642668918814133981159210013185007430448829612312590750966052218329613009885758487725012645183399374446966400343710500229743517994579512211778305821315452037663448384359008712746554743563695597899962398792198953207386563015713325853243368905934724894037960940203172745457473361221952022780818119733939386730022286037753659179995599044998299225384675544288247773022441761574512805080011426952888524431496801701343791715866682983213421176407470580958153944894180372833898396951358591123637162223275455018230132572369087231185427157437735113245037721132363363089820207760870493064985233254236978437834883425069210661667842530222643416477193000685852204548497327600396736361471995966156388125617461662973714871175165393803037986068831895152702187291043143587354876070398215076956346546896870756726174343734967388568991503280563232502639127051069490770269775485598919487019822923070203239399599113857677814872931597959356897737116181935057355145856679107041868462403503056312048753370610618818479313717984973731187149395837803235622283351016727908384161231986685723451668915759269631965011148211781992729321011891994427417806321293428256761047272995307509396567383043817980953183716007888971731311055776572987330685771351381621753829368484649954731777285849850227974618409751398604232248583442941535515169271016821507528312535692304613067872048115577282775226049960431806664829243853690181474548772162891717351444657278575921596333661131649399790050435650930799521456256533398680540530387079828934996959383096402932596561382460657697600504830550396946792160710884086957868097199833400518561815696723401787241109245791997501020486315207488798370181773331571637855818818392178904936144338020981349706959770552392103705300176739575287920891298039747361395434819278019236107227722831211006920481041916074835301721327955081851450334634328977309235312358912146091192117139933462833966638675095982453151036275426337143448474443512834273818436156178140720856450886486201695969071980754475666969143707675261793429105094105021435989964701996111617305161623537608389993066191482747214723924559064471191337079455023930267826784331775024635894903570649051429331250896504549265516421641546270315375284888185589436028704563950029840541115513353331555002418537800186372685656829267765364153612999333131781815498749534656426378436263536479397639930741990815861876033747239238520703280868684915525975492553554476848292646371118646096175276178571398658703852116237716162230718602325016792105123734576543387659370675079823329947176207503269312966721041104200890431451709685865411433290248443977831955806443786004586882170906819390531266590433033160649838162339220211433315462183511171802272865747569241746467509706961938267318421056255772004580063086623783804291288101078815931516136062215315011494108563515891177534955673425966444579329085806278042141202822918075590913677956615462546351505567372785876175190154408568738375966719975425928213252148265376654742080938474985605022522680070423638096126115059709750701161433668387743405972262513648627340520827876331741697501676338464739571415652430554287515985102424229977317892089939697064501164207042372245198839273275852365080938798049588329474047396348021286640487525535835710829960302504501690698457360747113272425617913260655466065868820632760299128672524045569246672596837372820282176555804907559021531314867069848612569843623896030864239871530039442189124840511198416141164018823179586578296067846193677171630606882168555712976966006745518181984561671462854924351736310328848101052875633695942109481414285832632383925818498983238607092334223794394099963340884089525233665632971418510954372377930853842944023749488952610251903043203815650502989059986529769404003730405991894336564742895176736999067802642747345202943584768239298864522853626742781553911719582631288576742515660004555411356243085629794582242993246103944810020372132627666332059477395566696381327419127139774701863345549345480875293533512958489088752720950646419079839808242575748317678381049153260998814285991785527435390648835193869871207192774945047028183521979946299078138528734048519270965094474584980049119031503884376949465263519088394544156521180204709593375392065997839454881390198958699127408741667861098986310619116674538804410255504517779335362842869106587579802474163349358644268640694474122251248280024770779495615147737535251591247605105847143837687925011749775121470676170688365777815820067342397333806988641971860623433269568646544165343060029519196303055694062276092092771104283160477696000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Factorial of 4000 takes:

Time difference = 90651[µs] (g++ -O0)
Time difference = 15621[µs] (g++ -Ofast)

Rationals(fractions):

Brat a(1, "34534534");
Brat b("-SomeNumbersAreHere::62", "-SomeNumbersAreHere::62");  // base 62
Brat c = "-9:10:79:100:16:3:35:72:76:15:11::101 / 2";          // base 101

a += b;
a *= c;

std::cout << "a = " << a << std::endl;
std::cout << "a b62 = " << a.base(62) << std::endl;
std::cout << "a point = " << a.point(50) << std::endl;
std::cout << "a point b62 = " << a.point(50, 62) << std::endl;

Output:

a = -8481309383972525015147919680/1364114093
a b62 = -b1SuMDAel1Q1KSPK::62/1ujGod::62
a point = -6217448692521150439.53872535792356189666607307751053342427421135073633
a point b62 = -7phYORB5xyv.xoRkTP8foonNxN1XMIa36GVhBAE59zioI0aAFYKQVLym6m6QrT::62