Arbitrary precision arithmetic with Ruby

Posted by macek on Stack Overflow See other posts from Stack Overflow or by macek
Published on 2010-05-19T16:04:30Z Indexed on 2010/05/19 16:10 UTC
Read the original article Hit count: 259

How the heck does Ruby do this? Does Jörg or anyone else know what's happening behind the scenes?

irb(main):001:0> 999**999

368063488259223267894700840060521865838338232037353204655959621437025609300472231530103873614505175218691345257589896391130393189447969771645832382192366076536631132001776175977932178658703660778465765811830827876982014124022948671975678131724958064427949902810498973271030787716781467419524180040734398996952930832508934116945966120176735120823151959779536852290090377452502236990839453416790640456116471139751546750048602189291028640970574762600185950226138244530187489211615864021135312077912018844630780307462205252807737757672094320692373101032517459518497524015120165166724189816766397247824175394802028228160027100623998873667435799073054618906855460488351426611310634023489044291860510352301912426608488807462312126590206830413782664554260411266378866626653755763627796569082931785645600816236891168141774993267488171702172191072731069216881668294625679492696148976999868715671440874206427212056717373099639711168901197440416590226524192782842896415414611688187391232048327738965820265934093108172054875188246591760877131657895633586576611857277011782497943522945011248430439201297015119468730712364007639373910811953430309476832453230123996750235710787086641070310288725389595138936784715274150426495416196669832679980253436807864187160054589045664027158817958549374490512399055448819148487049363674611664609890030088549591992466360050042566270348330911795487647045949301286614658650071299695652245266080672989921799342509291635330827874264789587306974472327718704306352445925996155619153783913237212716010410294999877569745287353422903443387562746452522860420416689019732913798073773281533570910205207767157128174184873357050830752777900041943256738499067821488421053870869022738698816059810579221002560882999884763252161747566893835178558961142349304466506402373556318707175710866983035313122068321102457824112014969387225476259342872866363550383840720010832906695360553556647545295849966279980830561242960013654529514995113584909050813015198928283202189194615501403435553060147713139766323195743324848047347575473228198492343231496580885057330510949058490527738662697480293583612233134502078182014347192522391449087738579081585795613547198599661273567662441490401862839817822686573112998663038868314974259766039340894024308383451039874674061160538242392803580758232755749310843694194787991556647907091849600704712003371103926967137408125713631396699343733288014254084819379380555174777020843568689927348949484201042595271932630685747613835385434424807024615161848223715989797178155169951121052285149157137697718850449708843330475301440373094611119631361702936342263219382793996895988331701890693689862459020775599439506870005130750427949747071390095256759203426671803377068109744629909769176319526837824364926844730545524646494321826241925107158040561607706364484910978348669388142016838792902926158979355432483611517588605967745393958061959024834251565197963477521095821435651996730128376734574843289089682710350244222290017891280419782767803785277960834729869249991658417000499998999

© Stack Overflow or respective owner

Related posts about ruby

Related posts about arbitrary-precision

  • Arbitrary precision arithmetic with Ruby

    as seen on Stack Overflow - Search for 'Stack Overflow'
    How the heck does Ruby do this? Does Jörg or anyone else know what's happening behind the scenes? irb(main):001:0> 999**999 36806348825922326789470084006052186583833823203735320465595962143702560930047223153010387361450517521869134525758989639113039318944796977164583238219236607653663113200177617597793217865870366077846576581183082787698201412402294867197567813172495806442794990281049897327103078771678146741952418004073439899695293083250893411694596612017673512082315195977953685229009037745250223699083945341679064045611647113975154675004860218929102864097057476260018595022613824453018748921161586402113531207791201884463078030746220525280773775767209432069237310103251745951849752401512016516672418981676639724782417539480202822816002710062399887366743579907305461890685546048835142661131063402348904429186051035230191242660848880746231212659020683041378266455426041126637886662665375576362779656908293178564560081623689116814177499326748817170217219107273106921688166829462567949269614897699986871567144087420642721205671737309963971116890119744041659022652419278284289641541461168818739123204832773896582026593409310817205487518824659176087713165789563358657661185727701178249794352294501124843043920129701511946873071236400763937391081195343030947683245323012399675023571078708664107031028872538959513893678471527415042649541619666983267998025343680786418716005458904566402715881795854937449051239905544881914848704936367461166460989003008854959199246636005004256627034833091179548764704594930128661465865007129969565224526608067298992179934250929163533082787426478958730697447232771870430635244592599615561915378391323721271601041029499987756974528735342290344338756274645252286042041668901973291379807377328153357091020520776715712817418487335705083075277790004194325673849906782148842105387086902273869881605981057922100256088299988476325216174756689383517855896114234930446650640237355631870717571086698303531312206832110245782411201496938722547625934287286636355038384072001083290669536055355664754529584996627998083056124296001365452951499511358490905081301519892828320218919461550140343555306014771313976632319574332484804734757547322819849234323149658088505733051094905849052773866269748029358361223313450207818201434719252239144908773857908158579561354719859966127356766244149040186283981782268657311299866303886831497425976603934089402430838345103987467406116053824239280358075823275574931084369419478799155664790709184960070471200337110392696713740812571363139669934373328801425408481937938055517477702084356868992734894948420104259527193263068574761383538543442480702461516184822371598979717815516995112105228514915713769771885044970884333047530144037309461111963136170293634226321938279399689598833170189069368986245902077559943950687000513075042794974707139009525675920342667180337706810974462990976917631952683782436492684473054552464649432182624192510715804056160770636448491097834866938814201683879290292615897935543248361151758860596774539395806195902483425156519796347752109582143565199673012837673457484328908968271035024422229001789128041978276780378527796083472986924999165841700049999899… >>> More

  • Arbitrary-precision random numbers in C: generation for Monte Carlo simulation without atmospheric n

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I know that there are other questions similar to this one, however the following question pertains to arbitrary-precision random number generation in C for use in Monte Carlo simulation. How can we generate good quality arbitrary-precision random numbers in C, when atmospheric noise isn't always… >>> More

  • Arbitrary-precision arithmetic Explanation

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I'm trying to learn C and have come across the inability to work with REALLY big numbers (i.e., 100 digits, 1000 digits, etc.). I am aware that there exist libraries to do this, but I want to attempt to implement it myself. I just want to know if anyone has or can provide a very detailed, dumbed… >>> More

  • The best cross platform (portable) arbitrary precision math library

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Dear ninjas / hackers / wizards, I'm looking for a good arbitrary precision math library in C or C++. Could you please give me some advices / suggestions? The primary requirements: It MUST handle arbitrarily big integers (my primary interest is on integers). In case that you don't know what the… >>> More

  • Arbitrary precision type

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Is there such a type\implementation in C#? It is needed to calculate figures up to 1010,000 magnitude. >>> More