PDA

View Full Version : Taking large floating input



7raTEYdCql
March 1st, 2009, 09:00 PM
When taking large floating input(eg:2.99999999999999999999). Python converts it to 3.0

How do i avoid such conversion, so that i get 2.99999999... as the value stored.

WW
March 1st, 2009, 10:04 PM
Floating point numbers in python (http://docs.python.org/tutorial/floatingpoint.html) are finite precision. If you really need arbitrary precision, libraries such as mpmath (http://code.google.com/p/mpmath/) are available.

CptPicard
March 1st, 2009, 11:10 PM
Look at the decimal module (class Decimal) for fixed point.

rharriso
March 2nd, 2009, 05:59 AM
There are string based libraries in C++ and java for handling arbitrarily large numbers, you should see if they exist for python.

kavon89
March 2nd, 2009, 06:08 AM
There are string based libraries in C++ and java for handling arbitrarily large numbers, you should see if they exist for python.

BigDecimal?

tneva82
March 2nd, 2009, 07:08 AM
BigDecimal?

Sounds what I used when I needed really BIG numbers for cryptograph program.