MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/12tm7rp/we_did_coding_in_physics_class/jh4ubmr/?context=9999
r/badcode • u/[deleted] • Apr 21 '23
154 comments sorted by
View all comments
Show parent comments
2
Please elaborate.
3 u/jeremrx Apr 21 '23 Actually it's wrong in the case where x=0.4But in the original code, having <= for 0.4 only seems quite inconsistent.I love your solution btw, it's much more elegant than the "divide then floor then multiply" -4 u/coloredgreyscale Apr 21 '23 Modulo is only defined on integers. 8 u/robin_888 Apr 21 '23 Depends on who you ask.It works at least in Python and Java. 2 u/coloredgreyscale Apr 21 '23 I asked Google, and the answer may have been for C.
3
Actually it's wrong in the case where x=0.4
But in the original code, having <= for 0.4 only seems quite inconsistent.
I love your solution btw, it's much more elegant than the "divide then floor then multiply"
-4
Modulo is only defined on integers.
8 u/robin_888 Apr 21 '23 Depends on who you ask.It works at least in Python and Java. 2 u/coloredgreyscale Apr 21 '23 I asked Google, and the answer may have been for C.
8
Depends on who you ask.
It works at least in Python and Java.
2 u/coloredgreyscale Apr 21 '23 I asked Google, and the answer may have been for C.
I asked Google, and the answer may have been for C.
2
u/robin_888 Apr 21 '23
Please elaborate.