1.2.2 • Published 6 years ago
math-trunc-x v1.2.2
math-trunc-x
Get the integer part of a number.
module.exports(value) ⇒ number ⏏
This method returns the integer part of a number by removing any fractional digits.
Kind: Exported function
Returns: number - The truncated number.
| Param | Type | Default | Description |
|---|---|---|---|
| value | number | The number to be truncate. |
Example
import mathTrunc from 'math-trunc-x';
mathTrunc(13.37); // 13
mathTrunc(42.84); // 42
mathTrunc(0.123); // 0
mathTrunc(-0.123); // -0
mathTrunc('-1.123'); // -1
mathTrunc(NaN); // NaN
mathTrunc('foo'); // NaN
mathTrunc(); // NaN