mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
big.js: add aliases .add, .mul, .sub (#24708)
This commit is contained in:
parent
02ff115ce9
commit
f87445077b
18
types/big.js/index.d.ts
vendored
18
types/big.js/index.d.ts
vendored
@ -102,6 +102,12 @@ export interface BigConstructor {
|
||||
export interface Big {
|
||||
/** Returns a Big number whose value is the absolute value, i.e. the magnitude, of this Big number. */
|
||||
abs(): Big;
|
||||
/**
|
||||
* Returns a Big number whose value is the value of this Big number plus n - alias for .plus().
|
||||
*
|
||||
* @throws `NaN` if n is invalid.
|
||||
*/
|
||||
add(n: BigSource): Big;
|
||||
/**
|
||||
* Compare the values.
|
||||
*
|
||||
@ -162,6 +168,12 @@ export interface Big {
|
||||
* @throws `NaN` if n is negative or otherwise invalid.
|
||||
*/
|
||||
mod(n: BigSource): Big;
|
||||
/**
|
||||
* Returns a Big number whose value is the value of this Big number times n - alias for .times().
|
||||
*
|
||||
* @throws `NaN` if n is invalid.
|
||||
*/
|
||||
mul(n: BigSource): Big;
|
||||
/**
|
||||
* Returns a Big number whose value is the value of this Big number plus n.
|
||||
*
|
||||
@ -196,6 +208,12 @@ export interface Big {
|
||||
* @throws `NaN` if this Big number is negative.
|
||||
*/
|
||||
sqrt(): Big;
|
||||
/**
|
||||
* Returns a Big number whose value is the value of this Big number minus n - alias for .minus().
|
||||
*
|
||||
* @throws `NaN` if n is invalid.
|
||||
*/
|
||||
sub(n: BigSource): Big;
|
||||
/**
|
||||
* Returns a Big number whose value is the value of this Big number times n.
|
||||
*
|
||||
|
||||
@ -86,6 +86,7 @@ function minusTests() {
|
||||
0.3 - 0.1; // 0.19999999999999998
|
||||
const x = new Big(0.3);
|
||||
x.minus(0.1); // '0.2'
|
||||
x.sub(0.1); // '0.2'
|
||||
}
|
||||
|
||||
function modTests() {
|
||||
@ -99,6 +100,7 @@ function plusTests() {
|
||||
const x = new Big(0.1);
|
||||
const y = x.plus(0.2); // '0.3'
|
||||
Big(0.7).plus(x).plus(y); // '1'
|
||||
Big(0.7).add(x).add(y); // '1'
|
||||
}
|
||||
|
||||
function powTests() {
|
||||
@ -138,6 +140,7 @@ function timesTests() {
|
||||
const x = new Big(0.6);
|
||||
const y = x.times(3); // '1.8'
|
||||
Big('7e+500').times(y); // '1.26e+501'
|
||||
Big('7e+500').mul(y); // '1.26e+501'
|
||||
}
|
||||
|
||||
function toExponentialTests() {
|
||||
|
||||
@ -88,6 +88,7 @@ function minusTests() {
|
||||
0.3 - 0.1; // 0.19999999999999998
|
||||
const x = new Big(0.3);
|
||||
x.minus(0.1); // '0.2'
|
||||
x.sub(0.1); // '0.2'
|
||||
}
|
||||
|
||||
function modTests() {
|
||||
@ -101,6 +102,7 @@ function plusTests() {
|
||||
const x = new Big(0.1);
|
||||
const y = x.plus(0.2); // '0.3'
|
||||
Big(0.7).plus(x).plus(y); // '1'
|
||||
Big(0.7).add(x).add(y); // '1'
|
||||
}
|
||||
|
||||
function powTests() {
|
||||
@ -140,6 +142,7 @@ function timesTests() {
|
||||
const x = new Big(0.6);
|
||||
const y = x.times(3); // '1.8'
|
||||
Big('7e+500').times(y); // '1.26e+501'
|
||||
Big('7e+500').mul(y); // '1.26e+501'
|
||||
}
|
||||
|
||||
function toExponentialTests() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user