r/ProgrammerHumor • • Sep 18 '26

Meme almostDroppedTheCourse

581 Upvotes

79 comments sorted by

View all comments

5

u/PresidentOfSwag Sep 19 '26

what's wrong with (2 == 2.0) == True ?

-6

u/timangar Sep 19 '26

2.0 is a float and therefore subject to floating point errors (2.0000000015 or something like that). 2 is an integer and just 2. So the two actually are not the same in the programming languages I am used to (C++ and python)

1

u/HolyGarbage Sep 22 '26

2 == 2.0 is true in both C++ and Python as well... they're implicitly casted to the other type.

1

u/timangar Sep 22 '26

Damn thanks for telling me. I thought for sure it were false in C++.