954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

VERY Large Numbers

I would like to make a LUDICROUSLY high number calculator in Python.
I am thinking 60 numbers and a decimal point. So numbers could be in a format like these:
60 numbers, 30 numbers decimal point 30 numbers (30nums.30nums), or decimal point 60
numbers (.60nums). E.g.

999,999,999,999,999,999,999,999,999,999.999999999999999999999999999999

But, I am wondering if Python has anything that would support such large numbers (including
math functions)? If not, I think I can program the whole process myself, but I'd prefer
not to. :)

Any ideas welcome!

- WolfShield

WolfShield
Posting Whiz in Training
236 posts since Oct 2010
Reputation Points: 28
Solved Threads: 4
 

There are different libraries for big floating numbers in python, most of them based on the gnu multiprecision library see bigfloat and gmpy and also clnum .

Gribouillis
Posting Maven
Moderator
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691
 
snippsat
Practically a Posting Shark
808 posts since Aug 2008
Reputation Points: 353
Solved Threads: 294
 

See decimal package:

>>> from decimal import *
>>> getcontext().prec = 100
>>> Decimal(1).exp()
Decimal('2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427')
>>> Decimal(1).exp()**34
Decimal('583461742527454.8814029027346103910190036592389411081057829421204316676742119505811471038583648840548')
>>>

It is missing trig functions however.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

Great!
I'll try BigFloat and Decimal!

Thanks a lot guys!

- WolfShield

WolfShield
Posting Whiz in Training
236 posts since Oct 2010
Reputation Points: 28
Solved Threads: 4
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: