[Tutor] Decimal truncation, rounding etc.

Luke Paireepinart rabidpoobear at gmail.com
Thu Oct 26 01:16:38 CEST 2006


Joe Cox wrote:
> My next project is to read a doc file and do some number editing.
> I can alter numbers in the Interactive Shell OK:
>  
> import math
> print round(7.12345,4)
> 7.1234
>  
> from decimal import*
> Decimal('7.00000').quantize(Decimal('1.000'),rounding = 
> decimal.ROUND_DOWN)
> Decimal("7.0000")
>  
> But when I go in to IDLE, I just don't seem to be able to make this work.
>
What have you tried?
> A typical line of code for me to read and edit will look like:
> G01 G91 X_7.12345_ Y_7.0000_ Z-0.0086 
> The underlines is what I need to edit, as above.
Okay, and what does it look like when you input these values?
Are you storing them in  Decimal instances, or floats, or what?

What exactly is it that doesn't work?


More information about the Tutor mailing list