UNPKG

896 BJavaScriptView Raw
1import { factory } from '../../utils/factory.js';
2var name = 'oct';
3var dependencies = ['typed', 'format'];
4/**
5 * Format a number as octal.
6 *
7 * Syntax:
8 *
9 * math.oct(value)
10 *
11 * Examples:
12 *
13 * //the following outputs "0o70"
14 * math.oct(56)
15 *
16 * See also:
17 *
18 * bin
19 * hex
20 *
21 * @param {number} value Value to be stringified
22 * @param {number} wordSize Optional word size (see `format`)
23 * @return {string} The formatted value
24 */
25
26export var createOct = factory(name, dependencies, (_ref) => {
27 var {
28 typed,
29 format
30 } = _ref;
31 return typed(name, {
32 'number | BigNumber': function numberBigNumber(n) {
33 return format(n, {
34 notation: 'oct'
35 });
36 },
37 'number | BigNumber, number': function numberBigNumberNumber(n, wordSize) {
38 return format(n, {
39 notation: 'oct',
40 wordSize: wordSize
41 });
42 }
43 });
44});
\No newline at end of file