[Tutor] Rounding number

2007-03-18 Thread Per Jr. Greisen

Hi,

I use the method from math in order to round off the number:

import math

a = 1.3

b = round(a,3)

which equals gives
b=1.4

is it possible to have the rounding such that
b = 1.400

so it keeps in my case the correct digits?

Any help appreciate. Thanks in advance



--
Best regards
Per Jr. Greisen
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Rounding number

2007-03-18 Thread Luke Paireepinart
Per Jr. Greisen wrote:
 Hi,

 I use the method from math in order to round off the number:

 import math

 a = 1.3

 b = round(a,3)

 which equals gives
 b=1.4

 is it possible to have the rounding such that
 b = 1.400
Trailing zeroes aren't significant values so the computer won't store it.
This rounding works when the rounded values don't have trailing zeroes, 
right?
It's possible to add these zeroes using string formatting, when you want 
to display them.
  %.3f % 1.4
'1.400'
See http://docs.python.org/lib/typesseq-strings.html for more 
information on string formatting operations.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor