I have googled over this,but couldn't find how, although it is a simple thing to answer for someone who knows it. I want to know how floating point can store large numbers which can't be stoed by integer representation. In the tutorials all that I could read about significand,exponent and bases but couldn't find my answer. Could anyone come up to solve it? For example,I have to represent a number larger than 2147483647 in a 32-bit system, then how it is done in floating point representation as opposed to integer representation.
Suppose you assume this convention: the last two digits of your integer denote the power-of-10 of the remainder. Then you can store numbers up to 21474835 * 10^99 in a single integer. (You would also need to program all arithmetic methods to use it a such.)
To use floating point numbers in the same way, you can use the same convention. Since a signed integer stores 9 decimals (10, but the first one can only be 0, 1 or 2), you could say that the decimal period is behind the first decimal. So to store "1234.56" you would use
123456004
-- the decimal point convention says this is "1.23456 times 10^4", and that is the same value you stored.
Astute readers will notice that you cannot store 'every possible number' this way. Exceeding the maximal number of allowed decimals, for example, will have them thrown away. You can also either not store negative numbers or values smaller than 1 (please deduce why).
How is this relevant to your question? This is exactly how floating point numbers are stored, albeit with other conventions than I outlined. A bit is set aside to use as sign; a number of bits hold the "decimal" part, and another set of bits hold the "exponent" part.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments