Re: [Tutor] Rounding off

2007-03-18 Thread Kent Johnson
Dick Moores wrote: >> >>> print round(2.1345, 3) >> 2.135 > > But now I have a question. > > >>> print "%.3f" % 22.1345 > 22.134 > > Why the 22.134's? Because neither 2.1345 nor 22.1345 can be represented exactly in floating point, and the errors are in the opposite direction: In [4]: repr

Re: [Tutor] Rounding off

2007-03-18 Thread Dick Moores
At 04:59 AM 3/18/2007, Dick Moores wrote: >At 03:08 AM 3/18/2007, Per Jr. Greisen wrote: > >Hi, > > > >Is there an easy way - a module or method for which you can round > >off number such as > > > >2.1345 to 2.135 > >Well, there are > > >>> print "%.3f" % 2.1345 >2.135 > >or > > >>> print round(2

Re: [Tutor] Rounding off

2007-03-18 Thread Kent Johnson
Dick Moores wrote: > At 03:08 AM 3/18/2007, Per Jr. Greisen wrote: >> Hi, >> >> Is there an easy way - a module or method for which you can round >> off number such as >> >> 2.1345 to 2.135 > > Well, there are > > >>> print "%.3f" % 2.1345 > 2.135 > > or > > >>> print round(2.1345, 3) > 2.13

Re: [Tutor] Rounding off

2007-03-18 Thread Dick Moores
At 03:08 AM 3/18/2007, Per Jr. Greisen wrote: >Hi, > >Is there an easy way - a module or method for which you can round >off number such as > >2.1345 to 2.135 Well, there are >>> print "%.3f" % 2.1345 2.135 or >>> print round(2.1345, 3) 2.135 Dick Moores __

[Tutor] Rounding off

2007-03-18 Thread Per Jr. Greisen
Hi, Is there an easy way - a module or method for which you can round off number such as 2.1345 to 2.135 Any help or advice appreciated? -- Best regards Per Jr. Greisen ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/t