this post was submitted on 04 Nov 2023
387 points (98.3% liked)
Programmer Humor
32495 readers
860 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Alternatively as both
floats
(32 bit) anddoubles
(64 bit) are represented in binary we can directly compare them to the possible values anint
(32 bit) and along
(64 bit) has. That is to say afloat
has the same amount of possible values as anint
does (anddouble
has the same amount of values as along
) . That's quite a lot of values but still ultimately limited.Since we generally use decimal numbers that look like this
1.5
or3.14
. It's setup so the values are clustered around 0 and then every power of 2 you have half as many meaning you have high precision around zero (what you use and care about in practice) and less precision as you move towards negative infinity and positive infinity.In essence it's a fancy fraction that is most precise when it's representing a small value and less precise as the value gets farther from zero