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

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -