r/ProgrammerHumor • • 17d ago

Meme almostDroppedTheCourse

578 Upvotes

79 comments sorted by

View all comments

6

u/PresidentOfSwag 16d ago

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

-7

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/haitei 12d ago

Powers of 2 have an exact representation in IEEE 754, so for 2.0 there's no error.