+ 3

I dont understand how does the two slashes work

19th Jan 2018, 2:35 AM
Andy Villa
Andy Villa - avatar
5 Antworten
+ 9
I'm guessing you're talking about floor division, also called integer division. if a / b is an integer, then a // b is that integer. if a / b is not an integer, then a // b is the next integer lower than a / b. e.g. 20 / 5 = 4, so 20 // 5 = 4 20 / 6 = 3.33333, so 20 // 6 = 3 because 3 is the next integer lower than 3.33333 It's a bit strange with negative numbers: -20 / 6 = -3.33333 and -20 // 6 = -4 because -4 is the next integer lower than -3.33333 Floor division and the modulo operator (%) kind of work together, if you think of the modulo as the remainder of a division: 20 // 6 = 3 and 20 % 6 = 2 because 2 = 20 - 3 * 6 so you get the relationship a = b * (a // b) + a % b oops got a bit carried away .... you weren't asking about double backslashes, were you? 🙃
19th Jan 2018, 4:17 AM
David Ashton
David Ashton - avatar
+ 3
thanks @David Ashton an impressive answer
19th Jan 2018, 4:56 PM
Mohammed
Mohammed - avatar
+ 2
I am asking it in python language what does // do and %do while calculating ..
19th Jan 2018, 9:18 AM
Andy Villa
Andy Villa - avatar
+ 1
What language? Backslashes or forward slashes?
19th Jan 2018, 3:06 AM
Daniel Muhlbach
Daniel Muhlbach - avatar