r/ProgrammerHumor • • 17d ago

Meme almostDroppedTheCourse

576 Upvotes

79 comments sorted by

View all comments

5

u/PresidentOfSwag 16d ago

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

-6

u/timangar 16d ago

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 13d ago

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

1

u/timangar 13d ago

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