How can be FLOAT grater than INT?

Started by
4 comments, last by Dark Schneider 16 years, 7 months ago
I am viewing the maximum number of any type and I read this: __int32 -> –2,147,483,648 to 2,147,483,647. float -> 3.4E +/- 38 (7 digits). then the float is able to be 3.4*10^38?, how it this possible if INT increments are by 1 and FLOAT increments are by <1 and both are 32 bits?. Am I wrong in anything?.
Advertisement
Quote:Original post by Dark Schneider
how it this possible if INT increments are by 1 and FLOAT increments are by <1 and both are 32 bits?

float increments are <1 only for small numbers.
Because of the way floats work. See IEEE 754.

Basically, you get a far higher range of values at the cost of some precision.
This is exactly the point of floating-point numbers. They are stored in what I've been brought up to call 'standard form', whereby the representation is split into the mantissa (a fixed list of digits) and the exponent (the position of the decimal place).

This exponential configuration means that the resolution of the number is not linear and depends on its size. So while an 'increment' may be fractionally small for small numbers, it is huge for big ones. You can verify this by adding 0.00001f to 1000000.0f and observing that it has no effect.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Floats are basically the same as what you see in windows calculator for very large numbers. It stores the mantissa and the exponent with real number being the mantissa being raised to the power of the exponent, loosing much precision at large values.

I don't know if this is any more clear...
- My $0.02
I see, Ok thanks, then I must take caution when manipulating big float values.

This topic is closed to new replies.

Advertisement