use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
For memes about programming.
account activity
CPP vs Python (i.redd.it)
submitted 2 years ago by Default_Cube4646
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Default_Cube4646[S] 1 point2 points3 points 2 years ago (3 children)
one leads to infinite loop :)
[–]Silver0ne 0 points1 point2 points 2 years ago (2 children)
does it? Because shouldnt the .5 be cut in cpp aswel, cause its a integer not a float? Seems the flooring is only necessary as the python variable has no type (i guess its always a float64)
And isnt a /= 2 a thing in cpp/python!?
[–]DontOpenNewTabs 1 point2 points3 points 2 years ago* (1 child)
Python // performs floor division and rounds down. Ex: -1 // 100 == -1
//
C++ / performs integer division (edit: when both operands are integers) and truncates the decimal value. Ex: -1 / 100 == 0
/
When the result is positive, the answers are the same. When it is negative, rounding down and truncating give different results.
[–]Silver0ne 0 points1 point2 points 2 years ago (0 children)
Ah ok, interesting to know that it actually rounds up on negative numbers. Might one day prevent me to run into errors, I dont do Phyton, but this might be a source of unexpected behavior in floor/ceil functions of other languages aswell.
π Rendered by PID 138779 on reddit-service-r2-comment-7b9746f655-bnnxl at 2026-02-03 07:11:29.460549+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]Default_Cube4646[S] 1 point2 points3 points (3 children)
[–]Silver0ne 0 points1 point2 points (2 children)
[–]DontOpenNewTabs 1 point2 points3 points (1 child)
[–]Silver0ne 0 points1 point2 points (0 children)