0
But why it is 0 - 5 remainder in modulus. If I in calculator 8 divide 9 I get remainder 8. Please can someone explain me?
22 Respuestas
+ 1
Remainder is the part that gets left if you divide a number by another but care about only whole part in the answer.
For example say the question is 9 % 10,
9 ÷ 10 equals 0.90 . we care only about the whole part and not the decimal so 0 becomes quotient and as 0 × 9 equals 0, The part that remain, 9 is the remainder in this case.
+ 3
Python 3 turns ints into floats during division i think.
+ 2
S. C. Thank you very much
+ 2
I was actually trying to show you how Modulo and division operator works
+ 1
no, remainder doesn't need to be from 0-5 only.
+ 1
Rytis Karalius
8 modulo 9
==========
Quotient = 0
Remainder = 8
+ 1
^^
+ 1
you need to declare float or double because 3.33333.. is real number
ex float a=20/6
cout<<a
the output is 3.33333
+ 1
exactly what you should get.
print(3.0 / 2) => 1.5 normal division as 2 × 1.5 = 3.0
print(3.0 // 2) => 1 floor division
print(3.0 % 2) => 1 modulo
as 1 × 2 + 1 = 3.0
in python 3
+ 1
Rytis Karalius
Now try print(3/2)
+ 1
you will still get 1.5 if you do 3/2 .
+ 1
Thank you all for help : )
0
8 divide 9 remainder 8 is true can you explain more about your problem?
0
🇻🇳GNAOH🇻🇳 So why when i use modulus operator the remainder os different?
0
🇻🇳GNAOH🇻🇳 Sorry the remainder is 8 but somebody said me that remainder only be from 0 -5 is this true
0
S. C. Can you explain me more about remainder?
0
20 % 6 is 2
but when I use this in calculator the remainder is 3. 20 / 6 is 3.3333
0
D'lite What I'm doing wrong?
0
Rytis Karalius
Go to the Python Playground, and type this: print(3.0/2)
0
D'lite I got 1.5