New // operator
by Matthew Sherborne other posts by this author
Apr 29 2002 10:23PM messages near this date
view in the new Beta List Site
Re: was (no subject) + new thread
|
Re: New // operator
On Python 2.2 I like the new div operator //, which I likened to =
Delphi's 'div' ie. Integer Division. However I surprised to realize that =
not only 5//2=3D=3D2 but that I can also say that 5 // 1.5 =3D=3D 3.0!
So I now realize that it is not "Integer Division", it is "Division with =
the result rounded down".
I hope that I will still be able to 5 // 1.5 in future versions of =
python because I'm putting it in my prorgam!
It's shorter than 'from math import floor; floor(5/1.5);'.
> >> from __future__ import
> >> 5 // 1.5
3.0
> >> 5 / 1.5
3.3333333333333335
Amazing! Thanks Guido and friends :)
Matthew Sherborne
Attachments:
unknown1
Thread:
Matthew Sherborne
Syver Enstad
Eric Sloane
Kari Hoijarvi
David Ascher
Jeff Shannon
David Ascher
|