Function: hexToIEEE754()
hexToIEEE754(
hex):number
Read a hexadecimal string as an IEEE 754 floating-point number, big-endian: 8 digits (4 bytes) as a single precision (32-bit) number, 16 digits (8 bytes) as a double precision (64-bit) number.
Parameters
hex
string
The hexadecimal digits, in either case, with or without a 0x/0X prefix ('3F800000', '0x3FF0000000000000').
Returns
number
The number, NaN and ±Infinity included.
Throws
When hex has a character which is not a hexadecimal digit.
Throws
When hex does not have 8 or 16 digits.
Example
typescript
import {hexToIEEE754} from 'lakutata/utils'
console.log(hexToIEEE754('3F800000'), hexToIEEE754('40490FDB'), hexToIEEE754('0x3FF0000000000000'))
//1 3.1415927410125732 1