OK, so I have a sudden urge to calculate really big numbers using Python. I've googled that python has no limit on the amount of characters that the number can you show. For example if I execute this:
import decimal
from decimal import Decimal
print(Decimal(641599888**5)**7)
The console will print out:
1.795766151434572597248927442E+308
If I again, run that through the print(Decimal...
print(Decimal(1.795766151434572597248927442E+308))
I get a massive number, with 309 digits:
179576615143457258700075088916205475704544728014348494378770201678625049728092745025740069670306256620000514266741755110731581159875713825371899514543785615348608901625672610723539647663835386726798483725257724640018240253857448988824387413636072364105453081728316837991208604405084707759438827801454827274240
Although, if I try and do the same with a higher power and do the same 2-step process, my result in the console will be:
Infinity
How can I make it that Python3 will not spit out infinity, but the whole massive number with ALL (say 10,000) it's digits? Is there a way to turn off getting "Infinity"?
You can convert your integer to a string and then print it:
>>> print(str(641599888**400))
8048441386979882758486771394164224556822337108565118014956984100152880757266958838553385533969353176216215181850352579864727837817623478476672833191813763684002690426067714798472130214469024891017409822276522548058521501685266755669150472329854051898539128189354472078835808660294650701900167146740304815888794398011432535818362041753656982583389181853570998273947641370908653948204262445368547776292572113031369595160517519155564749348226249370948936641124312625072828392497835468963677301505354817438058383095727046214632315478083369322143468842607091212399475342646056830359783665597142625773606888748703243400225378854041306744761434052303520192991302720113562233414921081774704463615740414111414790521762117113968141300546391525896954880281924819559059834197327163013763080234011665186367164741999939376378515771006902888219894472282038215670909738825704129841134857715655738157964213327751612652186324088895644220436965335846441913700984376165180423488862470610175457677701049250355396942002841591853019757574259119490253422150142775150235112642390532148332002788780153956029779703788892224614845428031105771217839374393226319399652783153473169209377536986580630853587091741805994162207493138498650581204079718045551874740229018796855973354283045875286578226229586597981016959439367765711497673618836344845684751246799676163030873619906825738165339845546307936066235529229290489966124794724169038856276715622111434818070258258973412241910147002579748480485716365243441368267095220175480322117495157704392243152683462323605154640062060147901011580436704644580785968802133642917146221447005353477173863191256859197985027214917637159035003856490878650622307717317423646752354670160240660111097949514953307628679894444075932532226193629667396628860018035988283142875716060887623137399540546643542719033624469353773521576529650424820979779098402554384444211495145422525202784074578433008251820629317434530209071701071686967714246470038658176955798624062883917772520935187756649607021730526925028230796184974091221256348165213623465112544051114059586563359874478403640620825070913371510060475733683267853392183018808017264171300009480891126118958580676270670936573881169495359249191287369884968626445039062044299704832015177249345974816212101438470766274838222049612717787010534265256367319033715525627326216669477629915212002171421208833673540952052859469790441088436153610687911128211024223039787379021833437151673403165978071087645171630668012362895724273716779217378392620327420640100111967210641551852840107326064803752439618691697977431599768479517251872541164965478924353868277368253540917569983210861780630188670862256079483134880586688027869926246579301177825399018838676880406791359407167928049043846606889791645466823027202748969858960437969383139176139385515819818002252617382778013616414149898626176640258835817437128396032524375407715873379751144391318999235889558966003402368208038058129238835612013319519657098318796662810943819163131404813435253225168130604773800665687837201940968620596378231724631161758415827491177393207253677905866936218867246342750097986739277327553218034062596255640457909046359322964557357162633797588851990643330209949658409547424732537512729225936836840062173801868201786508487585882499465004889502455006281076192733776883309460355979660579752995385445058713680293236638548935089434860939982380038003746800722348527281707086301756673790952136661827393992935833896285365526237940901749781787072840471272943939485718148719799385109864186119144555607898915322783743373226683846885376
Note that this will not work when precision is required (i.e. floating point), since some kind of rounding is done here.
Edit thanks to Mark Dickinson:
conversion to str
is not required