* Returns IntegerPart(n). * @see https://webidl.spec.whatwg.org/#abstract-opdef-integerpart * @param {number} n Numeric value. * @returns {number}
(n)
| 171 | * @returns {number} |
| 172 | */ |
| 173 | function integerPart(n) { |
| 174 | // Web IDL IntegerPart steps 1-3: floor(abs(n)), restore the sign, |
| 175 | // and choose +0 rather than -0. |
| 176 | const integer = MathTrunc(n); |
| 177 | return integer === 0 ? 0 : integer; |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Rounds to the nearest integer, choosing the even integer on ties. |
no outgoing calls
no test coverage detected
searching dependent graphs…