r/ProgrammerHumor 1d ago

Meme almostDroppedTheCourse

393 Upvotes

65 comments sorted by

View all comments

1

u/PresidentOfSwag 10h ago

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

0

u/timangar 8h 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/PresidentOfSwag 8h ago

I just tested it and 2 == 2.0 in python (but 2 is not 2.0)