On Wednesday, 7 September 2016 at 16:04:05 UTC, Nick Treleaven
wrote:
On Wednesday, 7 September 2016 at 15:15:03 UTC, John Colvin
wrote:
python3 uses / for floating point division and // for integer.
I really like the distinction, although I would prefer if /
was disallowed on integer operands entirely, i.e. 3/2.0 is ok
but 3/2 is not, that would be an error and you'd have to do 3
// 2
Personally I agree. A more nuanced solution is filed here:
https://issues.dlang.org/show_bug.cgi?id=12452
At the end of the description, Don is quoted:
It is indeed a common floating-point bug.
...
WOW, I didn't know python 3 fixed this issue, and I just found
out that python 2 can also do it by importing from future.
I have been using python 2.7 at my work for several years without
knowing this and ran into this issue so many times, stupid me.
Thanks for the info, I will update my python code asap. (In my
defense, I am not a full time programmer).
In D though, all solutions seem to add noise at the usage site,
template solution with alias this might be the cleanest to
retrofit all integers with floating point division.
- Sai