MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / bitsRequired

Function bitsRequired

src/lib/bytes.ts:42–47  ·  view source on GitHub ↗
(n: number, roundUp?: boolean)

Source from the content-addressed store, hash-verified

40export const getInclusionMask = (bits: number) => `0x${maxUint(bits).toString(16)}`
41
42export const bitsRequired = (n: number, roundUp?: boolean): number => {
43 let a = Math.ceil(Math.log2(n + 1));
44 return (roundUp && a % 8) ? a + (8 - (a % 8)) : a
45 // let m = a % 8;
46 // return m == 0 ? a : a + 8 - m;
47};

Callers 1

handleTypeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected