Take the 2-minute tour ×

I was looking at the Golden Ratio formula for finding the nth Fibonacci number, and it made me curious.

I know Python handles arbitrarily large integers, but what sort of precision do you get with decimals? Is it just straight on top of a C double or something, or does it use a a more accurate modified implementation too? (Obviously not with arbitrary accuracy. ;D)

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Python floats use the double type of the underlying C compiler. As Bwmat says, this is generally IEEE-754 double precision.

However if you need more precision than that you can use the Python decimal module which was added in Python 2.4.

Python 2.6 also added the fraction module which may be a better fit for some problems.

Both of these are going to be slower than using the float type, but that is the price for more precision.

share|improve this answer



there's also the decimal module for arbitrary precision floating point math

share|improve this answer

Your Answer


