/** * Round a value towards minus infinity, floor(x) * @param {Number | Complex} x * @return {Number | Complex} res */ function floor(x) { if (isNumber(x)) { return Math.floor(x); } if (x instanceof Complex) { return new Complex ( Math.floor(x.re), Math.floor(x.im) ); } // TODO: implement array support // TODO: implement matrix support throw newUnsupportedTypeError('floor', x); } math.floor = floor; /** * Function documentation */ floor.doc = { 'name': 'floor', 'category': 'Arithmetic', 'syntax': [ 'floor(x)' ], 'description': 'Round a value towards minus infinity.' + 'If x is complex, both real and imaginary part are rounded ' + 'towards minus infinity.', 'examples': [ 'floor(3.2)', 'floor(3.8)', 'floor(-4.2)' ], 'seealso': ['ceil', 'fix', 'round'] };