+ 1

How to divide two integers?

3rd Sep 2019, 2:37 AM
Yashroxx Rocky
Yashroxx Rocky - avatar
3 Réponses
+ 5
In Python, the integer division operator is //
3rd Sep 2019, 3:13 AM
Sonic
Sonic - avatar
+ 3
In what language? Your profile says you are learning C and Java, so here: C: int x = 8; int y = 4; int z = x / y; printf("%d", z); Java: int x = 8; int y = 4; System.out.println(x / y);
3rd Sep 2019, 2:40 AM
Daniel C
Daniel C - avatar
0
to add to @sonic because the question is a bit ambiguous: // will divide to integers and return an integer but the integer will be rounded down (not towards zero, but down) so negative results such as -3,5 will become -4 it is important to realise the fact that you will lose a part of you value with //
3rd Sep 2019, 5:31 AM
Brave Tea
Brave Tea - avatar