Skip to content

Commit 21646af

Browse files
refactor(binary): internal update float<>int conversions, migrate IS_LE flag
- update to re-use LE/BE buffers - migrate `IS_LE` to endianess.ts
1 parent a54ca91 commit 21646af

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

packages/binary/src/float.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
import type { FnN, FnN2, FnN3 } from "@thi.ng/api";
3-
4-
const F64 = new Float64Array(1);
5-
const F32 = new Float32Array(F64.buffer);
6-
const U8 = new Uint8Array(F64.buffer);
7-
const I32 = new Int32Array(F64.buffer);
8-
const U32 = new Uint32Array(F64.buffer);
9-
10-
/**
11-
* This value is true iff the environment is Little Endian.
12-
*/
13-
export const IS_LE = ((U32[0] = 1), U8[0] === 1);
3+
import { IS_LE } from "./endianess.js";
4+
import { F32, F64, I32, U32 } from "./buffers.js";
145

156
export const floatToIntBits: FnN = (x) => ((F32[0] = x), I32[0]);
167

0 commit comments

Comments
 (0)