First page Back Continue Last page Overview Text

Notes:


Converting to integer can be done two ways. Converting by truncation is quite easy... just use the standard int() function.

But rounding is somewhat trickier. You need to use the quantize() method. What quantize does is to take an “example” decimal, and rounds off the existing decimal to have the same exponent as the example.

Note that the built-in round() function won't do the job because that converts to floats.