Long Integer and Float
architecture, c, c++, floating-point, types
Solution
Integers are stored like this:
- 1 bit for the sign (+/-)
- 31 bits for the value.
Floats are stored differently, giving greater range at the expense of accuracy:
- 1 bit for the sign (+/-)
- N bits for the mantissa S
- M bits for the exponent E
Float is represented in the exponential form: (+/-)S*(base)^E
BTW, "long" isn't always 32 bits. See this article.
Problem
If a Long Integer and a float both take 4 bytes to store in memory then why are their ranges different?