[Tutor] Rounding to n significant digits? (original) (raw)
Alan Gauld alan.gauld at blueyonder.co.uk
Sun Jul 4 13:14:11 EDT 2004
- Previous message: [Tutor] Rounding to n significant digits?
- Next message: [Tutor] Rounding to n significant digits?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Gregor,
def engroundton(x,n): man,exp = roundton(x, n).split("e") # contains error-handling sh=int(exp)%3 return "%.*fe%+04i" % (n-1-sh,float(man)*10**sh,int(exp)-sh)
Eek! Are you sure that last line is Python and not Perl?
Winner of this months obfuscated tutor code I think...
I'll take your word for it that it works.
;-)
Alan G
- Previous message: [Tutor] Rounding to n significant digits?
- Next message: [Tutor] Rounding to n significant digits?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]