Package Exports
- extra-number
Readme
A number is a mathematical object used to count, measure, and label.
📦 Node.js,
🌐 Web,
📜 Files,
📰 Docs.
📘 Wiki.
Number type is double-precision 64-bit binary format IEEE 754 value. Includes notation conversion functions, as well as utilities.
The bit is a basic unit of information in information theory, computing. This
package includes bit twiddling hacks by Sean Eron Anderson and many others.
JavaScript converts a Number (a 64-bit floating point number) to a 32-bit
integer when bitwise operators (such as |) are applied. All bitwise operations
are performed on 32-bit integers.
This package is available in Node.js and Web formats. The web format
is exposed as extra_bit standalone variable and can be loaded from
jsDelivr CDN.
Stability: Experimental.
const number = require('extra-number');
// import * as bit from "extra-bit";
// import * as bit from "https://unpkg.com/extra-bit/index.mjs"; (deno)
number.isPrime(53);
// true
number.properDivisors(6);
// [1, 2, 3]
number.round(9.1357, 0.05);
// 9.15
number.significantDigits(0.0034);
// 2
// TOFIX:
// number.fromRoman('DCXLIX');
// 649
// number.toScientific(695700000);
// '6.957×10⁸' (radius of Sun in m)Index
| Property | Description |
|---|---|
| is | Checks if value is a number. |
| isPrime | Checks if a number is prime. |
| compare | Compares 2 numbers. |
| round | Rounds number to specific precision. |
| ceil | Rounds up number to specific precision. |
| floor | Rounds down number to specific precision. |
| lerp | Gives a number based on weight, within given range. |
| clamp | Limits a number within given range. |
| map | Converts a number from one range to another. |
| aliquotSum | Gives sum of all proper divisors of n. |
| properDivisors | Gives a list of numbers that n is divisible by, except itself. |
| significantDigits | Counts the number of significant digits of a number. |
| fromWords | Converts number in words to number. |
| fromRoman | Converts roman numerals to number. |
| toRoman | Converts number to roman numerals. |
| fromScientific | Converts scientific notation to number. |
| toScientific | Converts number to scientific notation. |
