[SciPy-user] scientific rounding

Lars Friedrich lfriedri@imtek...
Mon Jan 7 09:18:56 CST 2008


Hello,

when printing numerical data, rounding is often desirable. I would like 
to do something like 'relative rounding'. What I mean is the following:

round(1.3) -> 1.0
round(1.3e-9) -> 0.0

What I would like to have is

newFunction(1.3) -> 1.0
newFunction(1.3e-9) ->1.0e-9

So I would like the newFunction to do the rounding with respect to the 
order of magnitude. Of course, it would be easy to write such a function 
(dividing by the log of the number, rounding, multiplying again), but my 
question is, if such a function is already available in numpy or scipy.

Thanks,
Lars

-- 
Dipl.-Ing. Lars Friedrich

Photonic Measurement Technology
Department of Microsystems Engineering -- IMTEK
University of Freiburg
Georges-Köhler-Allee 102
D-79110 Freiburg
Germany

phone: +49-761-203-7531
fax:   +49-761-203-7537
room:  01 088
email: lars.friedrich@imtek.de


More information about the SciPy-user mailing list