caoge c760052ff9 机车状态修改 | 8 ヶ月 前 | |
---|---|---|
.. | ||
esm | 8 ヶ月 前 | |
lib | 8 ヶ月 前 | |
LICENSE | 8 ヶ月 前 | |
README.md | 8 ヶ月 前 | |
package.json | 8 ヶ月 前 |
A JavaScript function to parse floating point hexadecimals as defined by the WebAssembly specification.
import parseHexFloat from '@webassemblyjs/floating-point-hex-parser'
parseHexFloat('0x1p-1') // 0.5
parseHexFloat('0x1.921fb54442d18p+2') // 6.283185307179586
This module is tested in two ways. The first one is through a small set of test cases that can be found in test/regular.test.js. The second one is non-deterministic (sometimes called fuzzing):
x
.y
in floating point hexadecimal format using the C standard library function printf
since C supports this format.parseHexFloat(y) === x
.By default one npm test
run tests 100 random samples. If you want to do more, you can set the environment variable FUZZ_AMOUNT
to whatever number of runs you'd like. Because it uses one child process for each sample, it is really slow though. For more details about the randomized tests see the source.