Which has more values, a 64-bit integer or a 64-bit float?
My answer is that float has more value because its more accurate.
But isn’t integer is always greater than a float ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are more unique values in a 64-bit integer (2^64 for a two’s complement machine).
However, a 64-bit float has much larger range of values.
This can be trivially reasoned about because a 64-bit integer has a unique bit pattern for each unique value (it is "100% efficient") while a 64-bit float has a dedicated sign bit (which allows for a -0, but -0 == 0 is true) as well as a few "special patterns" (e.g.
NaN, which has multiple representations) thereby reducing the total number of unique values the float can represent.See the IEEE-754 article on Wikipedia and see the sections on the Representation of non-numbers