03-16-2022 05:59 AM
Hello,
I'm trying to perform a conversion from unsigned binary to floating point type but I'm not sure how to perform this conversion correctly. Here is the binary data structure below.
The data contains 3 words as shown where S is the sign bit, M is mantissa and Exp is the exponent. Any assistance will be appreciated. Thanks
Word3 Word2 Word1
Byte2 Byte 1 Byte2Byte1 Byte2Byte1
7..0 7...0 7...0 7...0 7...0 7....0
S M M M M M Exp
03-16-2022 06:15 AM - edited 03-16-2022 06:19 AM
Hi SolPS,
@SolPS wrote:
The data contains 3 words as shown where S is the sign bit, M is mantissa and Exp is the exponent.
So you get 6 bytes (not 4 bytes like SGL and also not 8 bytes like DBL)?
Is the mantissa with first 1 omitted (like IEEE754) or does it include the most significant 1? (Does your float numeric allow for un-normalized mantissa?)
Given the unusual byte count:
What does the Sign bit signal? Does TRUE mark a negative number?
What does the Exponent represent? Is it a signed I8 value or an unsigned U8 value? Is there a specific offset or/and any special values?
03-16-2022 06:32 AM
Hi GerdW,
Yes you get 6bytes and not the 4 and 8 bytes of the SGL and DBL. Yes I the mantissa is omitted and does not include the most significant 1.
The sign bit is for negative or positive number. I think the exponent is an I8. There is no specific offset or special values.
03-16-2022 07:11 AM - edited 03-16-2022 07:15 AM
So are you converting TO this floating point format? What's the source data?
Edit, nvm, the Unsigned Binary is as you show, and you want an IEEE-754 conforming DBL as output?
03-16-2022 07:14 AM - edited 03-16-2022 07:15 AM
Hi SolPS,
it always help when you would link to a manual describing that numeric format…
Some bitbanging:
(Tried to follow the usual DBL specifications, but check for errors…)
03-16-2022 07:26 AM
Thanks GerdW. I will try out your example. Much appreciated.
03-16-2022 08:21 AM
@GerdW wrote:
Hi SolPS,
it always help when you would link to a manual describing that numeric format…
Some bitbanging:
(Tried to follow the usual DBL specifications, but check for errors…)
I think that 33 for the mantissa length should be 39 (5 bytes*8bits/byte - 1bit = 39bits)
03-16-2022 08:40 AM
Yes you are correct. I have not tried out it yet but I will let you know when I do. Again thanks for the help..