Ttelmah Guest
|
|
Posted: Wed Oct 12, 2005 4:50 am |
|
|
It's in the manual.
However just to confuse you, while the paper manual desribes the definition, the electronic version only gives the examples, without the description!....
The definition is:
Byte1 8bit exponent, with 7F bias
Bytes 2,3,4 23bit mantissa, with LSB in byte 4, and sign in the MS
bit of byte 2.
This only differs from the IEEE format, in the placement of the parts. So you can convert between the formats by just moving the sign bits around. In common with the IEEE format, the mantissa is normalised to a 24bit value with a leading '1', and then this one is dropped in storage, so there is effectively 24bit precision in the mantissa.
These routines convert to/from IEEE formats, so you should be able to look up the IEEE information, and then compare this to the CCS storage:
Code: |
void toccs(int *Value) {
//program to convert a 4 bytes 'word' from IEEE to CCS format
int1 sign;
sign = shift_left(&Value[1],1,0);
sign = shift_left(&Value[0],1,sign);
shift_right(&Value[1],1,sign);
}
void toIEEE(int *Value) {
//complement to the above
int1 sign;
sign = shift_left(&Value[1], 1, 0);
sign = shift_right(&Value[0], 1, sign);
shift_right(&Value[1], 1, sign);
}
|
Calling these with a pointer to a float, changes the bit formats as required.
Best Wishes |
|