mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif
47 lines (45 loc) • 1.08 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createHex = void 0;
var _factory = require("../../utils/factory.js");
var name = 'hex';
var dependencies = ['typed', 'format'];
/**
* Format a number as hexadecimal.
*
* Syntax:
*
* math.hex(value)
*
* Examples:
*
* math.hex(240) // returns "0xF0"
*
* See also:
*
* oct
* bin
*
* @param {number | BigNumber} value Value to be stringified
* @param {number | BigNumber} wordSize Optional word size (see `format`)
* @return {string} The formatted value
*/
var createHex = exports.createHex = (0, _factory.factory)(name, dependencies, function (_ref) {
var typed = _ref.typed,
format = _ref.format;
return typed(name, {
'number | BigNumber': function numberBigNumber(n) {
return format(n, {
notation: 'hex'
});
},
'number | BigNumber, number | BigNumber': function numberBigNumberNumberBigNumber(n, wordSize) {
return format(n, {
notation: 'hex',
wordSize: wordSize
});
}
});
});
;