Is 10//3 is the same with (int)(10/3) in C lang? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 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 Antworten
+ 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