why does python round down? eg -12/10 = -2 -
i saw twitter post pointing out -12/10 = -2 in python. causes this? thought answer should (mathematically) one. why python "literally" round down this?
>>> -12/10 -2 >>> 12/10 1 >>> -1*12/10 -2 >>> 12/10 * -1 -1
this due int rounding down divisions. (aka floor division)
>>> -12/10 -2 >>> -12.0/10 -1.2 >>> 12/10 1 >>> 12.0/10 1.2
Comments
Post a Comment