+ 1

Why the results are different? (floor division)

Why they are not the outputs 3 and -3 or 4 and -4? print (-11//3) # output -4 print (11//3) # output 3

22nd Mar 2017, 11:31 AM
Javier I. Rivera R.
Javier I. Rivera R. - avatar
2 Respostas
+ 11
Floor division works this way - it does not round to zero. Rather, it always returns the next lower integer, whether positive or negative.
22nd Mar 2017, 11:44 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar