Files
scriptc/packages/compiler/src/format-integer.ts
Chris Tate c08ab955ae Enforce linting and consistent source formatting
- Enforce oxlint and oxfmt for owned JavaScript and TypeScript with independent CI checks.
- Preserve compiler import boundaries and protected fixtures while cleaning up lint findings.
- Standardize source formatting and validate import, fixture, and embedded-source protections.
2026-10-05 17:51:24 -05:00

14 lines
533 B
TypeScript

/** Exact integer spelling shared by frontend inspection and code emission.
* Division preserves all safe integer bits without general radix conversion. */
export function unsignedHex(value: number): string {
if (!Number.isSafeInteger(value) || value < 0)
throw new RangeError("hexadecimal value must be a nonnegative safe integer");
const digits = "0123456789abcdef";
let result = "";
do {
result = digits.charAt(value % 16) + result;
value = Math.floor(value / 16);
} while (value !== 0);
return result;
}