+ 1
Is 10//3 is the same with (int)(10/3) in C lang?
Is 10//3 is the same with (int)(10/3) in C lang?
3 Answers
+ 13
10/3 in C will result in floor division without needing explicit cast to integer.
It is more accurate to say that 10//3 in Python is the same as int(10.0/3.0).
+ 3
Yes.
10//3 is floor division.
(int)(10/3) is the conversion of datatype to integer, which only needs the integer part of the float. Pretty much what floor division does
+ 2
Wait what? So is Python an oddball?