Float division of big numbers in python -
i have 2 big numbers a
, b
of length around 10000, such a <= b
. now, have find c = / b
, upto 10 places of decimal, how do without loosing precision?
the decimal
module should work. seen in tigerhawkt3's link, can choose number of decimal places quotient should be.
from decimal import * getcontext().prec = 6 = float(raw_input('the first number:')) #can int() if needed b = float(raw_input('the second number:')) c = decimal(a) / decimal(b) print float(c)
Comments
Post a Comment