source: trip-planner-front/node_modules/@webassemblyjs/ieee754/esm/index.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1000 bytes
Line 
1import { write, read } from "@xtuc/ieee754";
2/**
3 * According to https://webassembly.github.io/spec/binary/values.html#binary-float
4 * n = 32/8
5 */
6
7export var NUMBER_OF_BYTE_F32 = 4;
8/**
9 * According to https://webassembly.github.io/spec/binary/values.html#binary-float
10 * n = 64/8
11 */
12
13export var NUMBER_OF_BYTE_F64 = 8;
14export var SINGLE_PRECISION_MANTISSA = 23;
15export var DOUBLE_PRECISION_MANTISSA = 52;
16export function encodeF32(v) {
17 var buffer = [];
18 write(buffer, v, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32);
19 return buffer;
20}
21export function encodeF64(v) {
22 var buffer = [];
23 write(buffer, v, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64);
24 return buffer;
25}
26export function decodeF32(bytes) {
27 var buffer = Buffer.from(bytes);
28 return read(buffer, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32);
29}
30export function decodeF64(bytes) {
31 var buffer = Buffer.from(bytes);
32 return read(buffer, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64);
33}
Note: See TracBrowser for help on using the repository browser.