[Tutor] Need more precise digits
Kirby Urner
urnerk@qwest.net
Sat, 01 Dec 2001 15:56:17 -0800
At 04:03 PM 12/1/2001 -0500, Lloyd Hugh Allen wrote:
>It's enough to cast either of the arguments to division as a float (in
>Python <= 2.1--haven't tried 2.2 yet, and can't remember whether integer
>division was canned yet by then, or if that's 2.3).
In 2.2 you have to go:
from __future__ import division
if you want division to default to floating point "true
division" i.e.
>>> 3/2 # 3 and 2 are both type int
1.5
That'll be phased out over time, meaning this type of
division will be the default.
Without importing anything, you can use the new // operator
any time, which forces an integer result e.g.
>>> 3.0//2.0
1.0
Kirby
Kirby