double-double
Version:
Pure double-double precision functions *with strict error bounds*.
21 lines (15 loc) • 588 B
text/typescript
// Modified from https://github.com/bartaz/ieee754-visualization/
// under the MIT license
// Copyright 2013 Bartek Szopka (original author)
/**
* Returns the ieee-574 8 bytes composing the given double, starting from the
* sign bit and ending in the lsb of the significand.
* e.g. 123.456 -> [64, 94, 221, 47, 26, 159, 190, 119]
* @internal
*/
function doubleToOctets(number: number) {
const buffer = new ArrayBuffer(8);
new DataView(buffer).setFloat64(0, number, false);
return Array.from(new Uint8Array(buffer));
}
export { doubleToOctets }