diff options
author | 2020-11-16 00:10:28 +0100 | |
---|---|---|
committer | 2020-11-16 00:10:28 +0100 | |
commit | e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch) | |
tree | 55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/@webassemblyjs/floating-point-hex-parser/README.md | |
download | website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2 website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip |
api, login, auth
Diffstat (limited to 'node_modules/@webassemblyjs/floating-point-hex-parser/README.md')
-rw-r--r-- | node_modules/@webassemblyjs/floating-point-hex-parser/README.md | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/node_modules/@webassemblyjs/floating-point-hex-parser/README.md b/node_modules/@webassemblyjs/floating-point-hex-parser/README.md new file mode 100644 index 0000000..648e09b --- /dev/null +++ b/node_modules/@webassemblyjs/floating-point-hex-parser/README.md @@ -0,0 +1,34 @@ +# Parser function for floating point hexadecimals + +[]() +[]() +[]() + +> A JavaScript function to parse floating point hexadecimals as defined by the [WebAssembly specification](https://webassembly.github.io/spec/core/text/values.html#text-hexfloat). + +## Usage + +```javascript +import parseHexFloat from '@webassemblyjs/floating-point-hex-parser' + +parseHexFloat('0x1p-1') // 0.5 +parseHexFloat('0x1.921fb54442d18p+2') // 6.283185307179586 +``` + +## Tests + +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](https://github.com/maurobringolf/@webassemblyjs/floating-point-hex-parser/blob/master/test/regular.test.js). The second one is non-deterministic (sometimes called *fuzzing*): + +1. Generate a random IEEE754 double precision value `x`. +1. Compute its representation `y` in floating point hexadecimal format using the C standard library function `printf` since C supports this format. +1. Give both values to JS testcase and see if `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](https://github.com/maurobringolf/@webassemblyjs/floating-point-hex-parser/tree/master/test/fuzzing). + +## Links + +* [maurobringolf.ch/2017/12/hexadecimal-floating-point-notation/](https://maurobringolf.ch/2017/12/hexadecimal-floating-point-notation/) + +* [github.com/xtuc/js-webassembly-interpreter/issues/32](https://github.com/xtuc/js-webassembly-interpreter/issues/32) + +* [github.com/WebAssembly/design/issues/292](https://github.com/WebAssembly/design/issues/292) |