+ 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?

9th Oct 2017, 11:09 PM
ģµœģ¤€ķ•œ
ģµœģ¤€ķ•œ - avatar
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).
10th Oct 2017, 2:21 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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
9th Oct 2017, 11:26 PM
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬ - avatar
+ 2
Wait what? So is Python an oddball?
10th Oct 2017, 2:31 AM
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬ - avatar