forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloat.js
More file actions
35 lines (27 loc) · 726 Bytes
/
float.js
File metadata and controls
35 lines (27 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @fileoverview Floating point glue code for JavaScript.
* @license Apache-2.0
*/
import { f64_pow } from "as-float";
/* eslint-disable no-undef */
const F64 = new Float64Array(1);
const F32 = new Float32Array(F64.buffer);
const I32 = new Int32Array(F64.buffer);
globalThis.f32_as_i32 = function f32_as_i32(value) {
F32[0] = value;
return I32[0];
};
globalThis.i32_as_f32 = function i32_as_f32(value) {
I32[0] = value;
return F32[0];
};
globalThis.f64_as_i64 = function f64_as_i64(value) {
F64[0] = value;
return i64_new(I32[0], I32[1]);
};
globalThis.i64_as_f64 = function i64_as_f64(value) {
I32[0] = i64_low(value);
I32[1] = i64_high(value);
return F64[0];
};
globalThis.f64_pow = f64_pow;