Skip to content

Commit

Permalink
refactor(binary): update little endian check (IS_LE const)
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jul 14, 2023
1 parent ebcfcc7 commit ee47a7f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/binary/src/float.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import type { FnN, FnN2 } from "@thi.ng/api";

const F64 = new Float64Array(1);
const F32 = new Float32Array(F64.buffer);
const U8 = new Uint8Array(F64.buffer);
const I32 = new Int32Array(F64.buffer);
const U32 = new Uint32Array(F64.buffer);

/**
* This value is true iff the environment is Little Endian.
*/
export const IS_LE = ((F64[0] = 2), U32[1] === 0x40000000);
export const IS_LE = ((U32[0] = 1), U8[0] === 1);

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

Expand Down

0 comments on commit ee47a7f

Please sign in to comment.