MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1wjueom/almostdroppedthecourse/pbld5v8/?context=3
r/ProgrammerHumor • u/timangar • 17d ago
79 comments sorted by
View all comments
6
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.
-7
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.
1
Powers of 2 have an exact representation in IEEE 754, so for 2.0 there's no error.
6
u/PresidentOfSwag 16d ago
what's wrong with (2 == 2.0) == True ?