09-05-2014 09:29 AM
Hi all,
so there is no particular difference when using SGL or FXP
Regards,
Abdelhak.
09-05-2014 09:32 AM - edited 09-05-2014 09:32 AM
09-05-2014 09:52 AM
@saketa wrote:
Hi all,
so there is no particular difference when using SGL or FXP
Regards,
Abdelhak.
a FXP is basically an integer with a divisor, SGL is a float with mantissa and exponent.
If FXP divisor is 1000 and you write 12345 it actually means 12.345 (in the 4 byte memory, in the code you dont have to worry about it)
A SGL would represent the same number as 0.12345 * 10^2 with 3 bytes as mantissa and 1 byte as exponent. (i can be a bit off or so, but as explanation it shouldn't matter)
This means a FXP have higher effective precision close to it's max, but lower at small values, where SGL can just lower exponent.
If a FXP needs to write a small value it need to fill up on 0's, while SGL changes exponent. This also means FXP is sensitive to decimal point placement, which divisor you're using.
One of FXPs benefits is that it uses the integer part of the hardware so it can be alot faster on some hardware.
/Y