python - What suppose to be the answer to 6/-132? -
this question has answer here:
in python, 6/-132
gets answer of -1
, should 0
?
what's rules behind it?
python floors result, means 1/2 floors zero, 1/-2 floors -1. different c, 'truncates toward 0'. afaik, languages follow c. python uses different rules keep division 'in sync' modulo. article job of explaining.
http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html
Comments
Post a Comment