mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
* chore(package): update standard to version 12.0.0
* update to new lint version with --fix
I believe this mainly adds whitespace to `{}`'s.
* Replace assert.equal with assert.strictEqual
This breaks a lot of tests which I will endevour to fix in the next
commits.
* Fix most errors due to assert.strictEquals
Some instances of `strictEquals` are replaced by `deepEquals`.
`toString` has been used to make some string comparisions explicit.
Tests will still fail untill #1236 and #1237 are fixed.
* Fix assertion erros due to -0
With node 10, assert.strictEqual no longer considers `0 === -0`.
I missed these first time round as I was using node 8.
* Put toString correct side of bracket
I was converting the constructor to a string rather
than the result of the computation. Oops.
* Fixed #1236: quantileSeq has inconsistant return
* Update package-lock
* Fixed #1237: norm sometimes returning a complex number instead of number
* Fix cli tests
* More changes for standardjs, and fixes in unit tests
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
'use strict'
|
|
|
|
const deepMap = require('../../utils/collection/deepMap')
|
|
|
|
function factory (type, config, load, typed) {
|
|
/**
|
|
* Round a value towards minus infinity.
|
|
* For matrices, the function is evaluated element wise.
|
|
*
|
|
* Syntax:
|
|
*
|
|
* math.floor(x)
|
|
*
|
|
* Examples:
|
|
*
|
|
* math.floor(3.2) // returns number 3
|
|
* math.floor(3.8) // returns number 3
|
|
* math.floor(-4.2) // returns number -5
|
|
* math.floor(-4.7) // returns number -5
|
|
*
|
|
* const c = math.complex(3.2, -2.7)
|
|
* math.floor(c) // returns Complex 3 - 3i
|
|
*
|
|
* math.floor([3.2, 3.8, -4.7]) // returns Array [3, 3, -5]
|
|
*
|
|
* See also:
|
|
*
|
|
* ceil, fix, round
|
|
*
|
|
* @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded
|
|
* @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value
|
|
*/
|
|
const floor = typed('floor', {
|
|
'number': Math.floor,
|
|
|
|
'Complex': function (x) {
|
|
return x.floor()
|
|
},
|
|
|
|
'BigNumber': function (x) {
|
|
return x.floor()
|
|
},
|
|
|
|
'Fraction': function (x) {
|
|
return x.floor()
|
|
},
|
|
|
|
'Array | Matrix': function (x) {
|
|
// deep map collection, skip zeros since floor(0) = 0
|
|
return deepMap(x, floor, true)
|
|
}
|
|
})
|
|
|
|
floor.toTex = { 1: `\\left\\lfloor\${args[0]}\\right\\rfloor` }
|
|
|
|
return floor
|
|
}
|
|
|
|
exports.name = 'floor'
|
|
exports.factory = factory
|