+ 1

Can someone explain how the % thing works

Can someone explain how the % thing works

18th Mar 2017, 1:57 PM
Eero
3 Respostas
+ 13
I found this hard to learn. It's important though. These answers are helpful! I finally fired up Python and just started throwing modulus examples at it...might be helpful for some people to do that..
20th Mar 2017, 3:32 PM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
+ 7
% or Modulo works by returning the remainder of division between 2 numbers. For example. x= 3%2, so x = 1 three divided by two leaves a remainder of one. Modulo returns the remainder only. remember that. Also Modulo only works with whole int numbers not floats. otherwise there would be no remainder
18th Mar 2017, 2:00 PM
Louis
+ 7
Worth to add that it might be working somewhat counterintuitively for negative numbers: 19 % 5 = 4 -19 % 5 = 1 -19 % -5 = -4 19 % -5 = -1
18th Mar 2017, 5:42 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar