[Tutor] wxPython? (fwd)
alan.gauld@bt.com
alan.gauld@bt.com
Tue, 1 Jan 2002 19:06:15 -0000
> Let me forward this to the rest of Tutor. I hate saying this, but I
> can't reproduce the wackiness.
Its standard integer division - the kind thats going away post V2.2
> def divide(x,y):
> return x/y
>
> for y in range(-10,10,1):
> x=2
> try:
> print divide(x,y), y
2/-10 all the way to 2/-3 gives a negative fraction
which is rounded down to -1
2/-2 = -1
2/-1 = -2
2/0 = exception
2/1 = 2
2/2 = 1
2/3 to 2/10 gives a fraction which is rounded down to 0.
> -1 -10
> -1 -9
> -1 -8
> -1 -7
> -1 -6
> -1 -5
> -1 -4
> -1 -3
> -1 -2
> -2 -1
> You are trying to divide by zero
> 2 1
> 1 2
> 0 3
> 0 4
> 0 5
> 0 6
> 0 7
> 0 8
> 0 9
QED.
Alan G.