Correctly handle SFLOAT values
Opened this issue · 0 comments
mrozycki commented
Certain fields in the BLE device specifications are defined to be SFLOAT, but instead are treated as u16 in code. For most cases, this should not be an issue (for integer values between 0 and 2^11-3 they are effectively the same), but could cause trouble if an error value is returned.
SFLOAT is defined as follows:
SFLOAT-Type ::= INT-U16
The 16–bit value contains a 4-bit exponent to base 10, followed by a 12-bit mantissa. Each is in twos-complement form.
Special values are assigned to express the following:
- NaN [exponent 0, mantissa +(2^11 –1) → 0x07FF]
- NRes [exponent 0, mantissa > –(2^11) → 0x0800]
- INFINITY [exponent 0, mantissa +(2^11 –2) → 0x07FE] – INFINITY [exponent 0, mantissa –(2^11 –2) → 0x0802]
- Reserved for future use [exponent 0, mantissa –(2^11 –1) → 0x0801]