[Tutor] / vs //

Kirby Urner urnerk@qwest.net
Wed, 20 Feb 2002 13:31:53 -0800


>
>PEP 238 says that a//b should act like floor(a/b) but you can
>see in this example that it doesn't since that result is 3.0 not 2.0
>
> >>> math.floor(3.9/1.3)
>3.0

I think a,b are supposed to be integers or the purposes of
this explanation, otherwise you get into floating point
weirdness (there's no terminating representation of 3.9 in
binary).

   >>> math.floor(39/13)
   3.0
   >>> 39//13
   3

Kirby