UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

16 lines (12 loc) 445 B
import { assert } from "../assert.js"; import { uint82hex } from "./uint82hex.js"; /** * Convert a decimal value to hex * @param {number} x generally expects b byte value, 0-255 * @returns {string} zero-padded value, for example instead of "0", will return "00" and instead of "F" will return "0F" */ export function dec2hex(x) { assert.greaterThanOrEqual(x, 0); const b = Math.round(x); return uint82hex(b); }