FactChecker said:
data compacted into bytes
Or data compacted into multibyte memory locations...
ChrisVer said:
Hmmm this sounds more like it... in fact there are comments but I don't quite understand them either, mainly because I don't understand them.
An example of what I mean is how the bits are packed into, say, a 32-bit floating point number. Per the IEE 754 standard for floating point numbers, a single-precision floating point number is divided into three parts:
bit 31 is the sign bit, with 0 for a positive number and 1 for a negative number
bits 23 through 30 hold the exponent, biased by 127 (meaning that the stored value is larger by 127 than the actual exponent of the number)
bits 0 through 22 hold the mantissa, or fractional part of the number.
The float value 4.125 in binary form would be 100.001
2, meaning
1 X 2^2 +
0 X 2^1 +
0 X 2^0 +
0 X 2^(-1) +
0 X 2^(-2) +
1 X 2^(-3). In normalized form (a sort of "scientific notation") this would be 1.00001
2 X 2
2. Note that in normalized form, the digit to the left of the "binary point" is always 1, so it doesn't need to be stored.
Since this number is positive, bit 31 would be 0.
Bits 23 through 30 would hold the exponent, which would be stored as the binary form of 129 (= 2 + 127).
Bits 0 through 22 would hold the mantissa, the part to the right of the "binary" point. For my example, the bit pattern would be 00001000000000000000000. Notice that this bit pattern agrees with what I showed as the normalized form, except for the leading 1 digit in the normalized form, which is implied.
To extract the various sections of numbers such as these, you need to use the binary AND operator to mask out any bits you don't want, and then you need to shift the resulting bit pattern to the right. To extract bits 23 through 30, you need a bit pattern with those bits set to 1 and all other bits set to 0. A hexadecimal number that does this is 0x07F800000. After ANDing with this mask, the resulting number needs to be shifted right by 23 bits.
Pretty low level stuff...