Skip to content

Commit

Permalink
feat(hex): add U64BIG
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 29, 2022
1 parent 03616b5 commit 06bcf05
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/hex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,20 @@ export const U48LE = (x: ArrayLike<number>, i: number) =>
* {@link U64BE} or {@link U64LE} for byte array based values (full 64bit range
* supported). Alternatively, use `BigInt(x).toString(16)`.
*
* Also see {@link U64BIG} for `bigint` version.
*
* @param x -
*/
export const U64 = (x: number) => U64HL(x / P32, x % P32);

/**
* Returns 64bit bigint as hex string.
*
* @param x
*/
export const U64BIG = (x: bigint) =>
U64HL(Number(x >> BigInt(32)), Number(x & BigInt(P32 - 1)));

/**
* Similar to {@link U64}, but takes the 64bit arg as 2x 32bit values.
*
Expand Down

0 comments on commit 06bcf05

Please sign in to comment.