mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
Add util funciton to format as hex
This commit is contained in:
committed by
David Lechner
parent
7a7eba407f
commit
6713afe198
@@ -13,3 +13,12 @@ export function assert(condition: boolean, message: string): void {
|
||||
throw Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a number as hex (0x00...)
|
||||
* @param n The number to format
|
||||
* @param pad The total number of digits padded with leading 0s
|
||||
*/
|
||||
export function hex(n: number, pad: number): string {
|
||||
return `0x${n.toString(16).padStart(pad, '0')}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user