mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
* setup linting with eslint-config-standard, prettier * [autofix] npm run lint -- --fix with new setup * [manual] fix types/ directory errors * [manual] fix linting errors in test/ directory * [manual] fix single linting error in src/ * revert ts-expect-error comment change * error on .only in mocha tests * fix test description typo * move some short objects to single line * add and gitignore eslintcache * individually suppress ts any * set --max-warnings to 0 * extract matrices to constants * update ts-expect-error comments
38 lines
787 B
JavaScript
38 lines
787 B
JavaScript
import { factory } from '../../utils/factory.js'
|
|
|
|
const name = 'oct'
|
|
const dependencies = ['typed', 'format']
|
|
|
|
/**
|
|
* Format a number as octal.
|
|
*
|
|
* Syntax:
|
|
*
|
|
* math.oct(value)
|
|
*
|
|
* Examples:
|
|
*
|
|
* //the following outputs "0o70"
|
|
* math.oct(56)
|
|
*
|
|
* See also:
|
|
*
|
|
* bin
|
|
* hex
|
|
*
|
|
* @param {number} value Value to be stringified
|
|
* @param {number} wordSize Optional word size (see `format`)
|
|
* @return {string} The formatted value
|
|
*/
|
|
|
|
export const createOct = factory(name, dependencies, ({ typed, format }) => {
|
|
return typed(name, {
|
|
'number | BigNumber': function (n) {
|
|
return format(n, { notation: 'oct' })
|
|
},
|
|
'number | BigNumber, number': function (n, wordSize) {
|
|
return format(n, { notation: 'oct', wordSize })
|
|
}
|
|
})
|
|
})
|