What is \\ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is \\

someone please tell me what is \\ . And an exemple like.. 20 \\ 4 = ?

27th Sep 2018, 8:26 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
5 Answers
+ 6
A small note to keep in mind: 10//3 = 3, but -10//3 = -4. The // operator is suggestively called the floor division operator. It produces the biggest integer smaller than the result of the division. In the second example above, -10/3 = -3.3333..., and -4 is the integer closest to -3.333... but smaller than it.
27th Sep 2018, 12:21 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 4
It's //, not \\. a // b is integer division. It tells you how many times a can be divided by b without a rest. 20 // 4 = 5 (because 5*4=20), 18 // 4 = 4 (because 4*4=16, so there is a rest of 2).
27th Sep 2018, 8:35 AM
Anna
Anna - avatar
+ 3
\ gives exact value of divide. 9\2=4.5 but \\ use for floor division. 9\\2 -------- 2| 9 |4 -------- 8 -------- 1 answer is 4 and here remainder is 1 which can find like this. 9%2=1
27th Sep 2018, 4:12 PM
Maninder $ingh
Maninder $ingh - avatar
+ 2
so... 10//3 = 3 because 3*3 = 9 ... the closest number?
27th Sep 2018, 8:48 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 2
Exactly. You can just calculate a/b and drop the decimals if there are any. 10/3 = 3.333333 => get rid of .333333 => 10//3 = 3 (always round down to the next integer)
27th Sep 2018, 8:53 AM
Anna
Anna - avatar