From 7237e9d34a61629d5bedce3b9cc46c8a1344d78a Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Wed, 1 May 2019 02:08:12 -0700 Subject: fs: add Deno.utime/Deno.utimeSync (#2241) --- js/util.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/util.ts') diff --git a/js/util.ts b/js/util.ts index 033a2f754..a035d761a 100644 --- a/js/util.ts +++ b/js/util.ts @@ -192,3 +192,18 @@ export function hasOwnProperty(obj: T, v: PropertyKey): boolean { } return Object.prototype.hasOwnProperty.call(obj, v); } + +/** + * Split a number into two parts: lower 32 bit and higher 32 bit + * (as if the number is represented as uint64.) + * + * @param n Number to split. + * @internal + */ +export function splitNumberToParts(n: number): number[] { + // JS bitwise operators (OR, SHIFT) operate as if number is uint32. + const lower = n | 0; + // This is also faster than Math.floor(n / 0x100000000) in V8. + const higher = (n - lower) / 0x100000000; + return [lower, higher]; +} -- cgit v1.2.3