[SciPy-user] help with precision for big numbers
Tue May 13 04:32:33 CDT 2008
First off, the first part of the expression s=... yields two different
answers, depending whether you cast Toff to a float or not.
In : 1.+Toff/Ton
In : 1.+float(Toff)/Ton
Which is the desired behavior for your problem?
The limit of precision of floating point numbers in native Python is
32-bit. Numpy defines extra scalar types and you will find most of the
ones supported by your machine in the numpy package. np.float64 will
give you 64-bit precision. There is a np.float96 for 96-bit floats but
I've never used it before.
Johann Cohen-Tanugi wrote:
> I am computing :
> In : for i in range(6):
> print "%.14g"%s
> A colleague using GSL and C code with double precision and long double (
> I am not sure whether he has a 64bit machine) obtained the following
> values :
> Close but not identical...... I was wondering if there is a way to
> increase numerical accuracy within scipy, assuming the standard behavior
> is not optimal with this respect. Or any other thoughts about these
> discrepancies? Or some nifty tricks to recover lost precision by
> organizing the computation differently?
> thanks in advance,
> SciPy-user mailing list
More information about the SciPy-user