this post was submitted on 05 Aug 2023
531 points (92.5% liked)

Programmer Humor

19623 readers
5 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 1 year ago (12 children)
[–] karlthemailman 5 points 1 year ago* (last edited 1 year ago) (11 children)

No, I get that. I'm sure the programming language design people know what they are doing. I just can't grasp how a double (which has to use at least 1 bit to represent whether or not there is a fractional component) can possibly store more exact integer vales than an integer type of the same length (same number of bits).

It just seems to violate some law of information theory to my novice mind.

[–] [email protected] 1 points 1 year ago (2 children)

I would need to look into the exact difference of double vs integer to know, but a partially educated guess is that they are referring to Int32 vs double and not Int64, aka long. I did a small search and saw that double uses 32 bits for the whole numbers and the others for the decimal.

[–] karlthemailman 1 points 1 year ago (1 children)

Yeah, that was my guess too. But that just means they could return a long (or whatever the 64 bit int equivalent in java is) instead of an int.

[–] [email protected] 1 points 1 year ago

Okay, so I dug in a bit deeper. Doubles are standardized as a 64 bit bundle that is divided into 1 signed bit, 11 exponetioal bits and 52 bits for decimal. It's quite interesting. As to how it works indepth, I probably will try to analyze a bit conversion if I can try something

load more comments (8 replies)
load more comments (8 replies)