Re: representations
- From: "Malcolm McLean" <regniztar@xxxxxxxxxxxxxx>
- Date: Mon, 26 Mar 2007 22:21:28 +0100
"Lane Straatman" <invalid@xxxxxxxxxxx> wrote in message > "Malcolm McLean" <regniztar@xxxxxxxxxxxxxx> wrote in message
Nearly right.Do you know what sign, mantissa and exponent mean, in relation to floating point numbers?There was a recent thread with Joe Wright and others that is probably as much as I know about it. The sign will take a bit. The mantissa is the a in the a**x. The exponent is the exponent, x.
IEEE standard floating point number use something very similar to scientific notation.
2000 is 2 * 10^3 in this notation.
By convention there is only one decimal digit before the point, so
2300 is 2.3 * 10^3
Numbers below one have negative exponents
0.023 = 2.3 * 10^-2 (mnemonic, count the zeroes, including the leading one)
2.3 itself is 2.3 * 10^0.
Floating point numbers are basically just the same, but in binary. Since the leading most significant binary digit must always be one, most representations including IEEE save a bit by omitting it. There is one exception to this rule, zero, so zero is represented specially by all bits zero. Since zero is 10^-inf, it makes sense to store exponents in a sign magnitude encoding rather than twos complement, so that 0 is the lowest, 1 = -127 or whatever, and so on. The sign bit is self explanatory.
Finally there are a few special representations for infinity, not a number, and what are called denormalised numbers, but you can ignore those for now.
By looking at the bit patterns in your compiler, you should be able to work out how many bits are allocated to each section, and what the exponent encoding is. Start with one and minus one to get the sign bit.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
.
- References:
- representations
- From: Lane Straatman
- Re: representations
- From: Army1987
- Re: representations
- From: Lane Straatman
- Re: representations
- From: Malcolm McLean
- Re: representations
- From: Lane Straatman
- representations
- Prev by Date: Re: Copying Structures
- Next by Date: Re: 'Portable' Measurement of Pointer Alignment in C?
- Previous by thread: Re: representations
- Next by thread: Re: representations
- Index(es):
Relevant Pages
|
Loading