-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(binary): add MSB_BITS8/16/32 LUTs
- Loading branch information
1 parent
ed66a64
commit e0eb47b
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
const defBits = (n: number) => | ||
new Array(n).fill(0).map((_, i) => 1 << (n - 1 - i)); | ||
/** | ||
* 8bit values in MSB order (i.e. MSB_BITS[0] = 0x80) | ||
*/ | ||
export const MSB_BITS8 = defBits(8); | ||
|
||
/** | ||
* 16bit values in MSB order (i.e. MSB_BITS[0] = 0x8000) | ||
*/ | ||
export const MSB_BITS16 = defBits(16); | ||
|
||
/** | ||
* 32bit values in MSB order (i.e. MSB_BITS[0] = 0x80000000) | ||
*/ | ||
export const MSB_BITS32 = defBits(32); | ||
|
||
export const MASKS = new Array(33).fill(0).map((_, i) => Math.pow(2, i) - 1); |