GitHub repository: github.com/Artem3348/Float
NPM package: npmjs.org/package/myfloat
NPM: npm install myfloat
<script src="https://unpkg.com/myfloat"></script>
import Float from 'myfloat';
const Float = require('myfloat);
-
Float.random(min, max);
-
Returns a floating point number from the range min, max.
-
Parameters:
- min (number)
- max (number)
-
Returns:
- number
-
const float = Float.random(20, 21); // random fraction number between 20 & 21
-
Float.is(number);
-
Checks if the passed number is a Float
-
Parameters:
- number (number)
-
Returns:
- boolean
-
Float.is(123); // false
Float.is("12.3"); // false
Float.is("js"); // false
Float.is("1.5.5"); // false
Float.is(new Float()); // true
Float.is(new Float(-1.7)); // true
Float.is(Float(1.7)); // true
Float.is(Float.random(20, 21)); // true
-
Float.like(value);
-
Checks if the passed value is like Float
-
Parameters:
- value (any)
-
Returns:
- boolean
-
Float.like(123); // false
Float.like("js"); // false
Float.like("12.3"); // true
Float.like(12.3); // true
-
Float.prototype.toFixed([digits]);
-
Similar to the Number.prototype.toFixed() method
-
Parameters:
- digits (number)
-
Returns:
- object
-
let float = new Float(1.234);
float.toFixed(); // Float { value: 1 }
let float1 = new Flaot(1.7545);
float.toFixed(2) // Float { value: 1.75 }
-
Float.prototype.equals(value);
-
Checks if the passed value is equal to Float.value
-
Parameters:
- value (number/string)
-
Returns:
- boolean
-
let float = new Float(1.5);
float.equal(1.5); // true