From 6416531210d6a22e582214a5f683334469c0970d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20B=C3=BCrk?= Date: Mon, 21 Apr 2014 00:42:58 +0200 Subject: [PATCH] #2073 BigInteger.js: added string signatures for all methods --- bigInteger/bigInteger-tests.ts | 19 ++++++++++++++++ bigInteger/bigInteger.d.ts | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/bigInteger/bigInteger-tests.ts b/bigInteger/bigInteger-tests.ts index 7940b8629..225b2118d 100644 --- a/bigInteger/bigInteger-tests.ts +++ b/bigInteger/bigInteger-tests.ts @@ -21,27 +21,35 @@ isBigInteger = x.abs(); isBigInteger = x.add( 0 ); isBigInteger = x.add( x ); +isBigInteger = x.add( "100" ); isBigInteger = x.compare( 0 ); isBigInteger = x.compare( x ); +isBigInteger = x.compare( "100" ); isBigInteger = x.compareAbs( 0 ); isBigInteger = x.compareAbs( x ); +isBigInteger = x.compareAbs( "100" ); isBigInteger = x.divide( 0 ); isBigInteger = x.divide( x ); +isBigInteger = x.divide( "100" ); isDivmod = x.divmod( 0 ); isDivmod = x.divmod( x ); +isDivmod = x.divmod( "100" ); isBoolean = x.equals( 0 ); isBoolean = x.equals( x ); +isBoolean = x.equals( "100" ); isBoolean = x.greater( 0 ); isBoolean = x.greater( x ); +isBoolean = x.greater( "100" ); isBoolean = x.greaterOrEquals( 0 ); isBoolean = x.greaterOrEquals( x ); +isBoolean = x.greaterOrEquals( "100" ); isBoolean = x.isEven(); @@ -53,40 +61,51 @@ isBoolean = x.isPositive(); isBoolean = x.lesser( 0 ); isBoolean = x.lesser( x ); +isBoolean = x.lesser( "100" ); isBoolean = x.lesserOrEquals( 0 ); isBoolean = x.lesserOrEquals( x ); +isBoolean = x.lesserOrEquals( "100" ); isBigInteger = x.minus( 0 ); isBigInteger = x.minus( x ); +isBigInteger = x.minus( "100" ); isBigInteger = x.mod( 0 ); isBigInteger = x.mod( x ); +isBigInteger = x.mod( "100" ); isBigInteger = x.multiply( 0 ); isBigInteger = x.multiply( x ); +isBigInteger = x.multiply( "100" ); isBigInteger = x.next(); isBoolean = x.notEquals( 0 ); isBoolean = x.notEquals( x ); +isBoolean = x.notEquals( "100" ); isBigInteger = x.over( 0 ); isBigInteger = x.over( x ); +isBigInteger = x.over( "100" ); isBigInteger = x.plus( 0 ); isBigInteger = x.plus( x ); +isBigInteger = x.plus( "100" ); isBigInteger = x.pow( 0 ); isBigInteger = x.pow( x ); +isBigInteger = x.pow( "100" ); isBigInteger = x.prev(); isBigInteger = x.subtract( 0 ); isBigInteger = x.subtract( x ); +isBigInteger = x.subtract( "100" ); isBigInteger = x.times( 0 ); isBigInteger = x.times( x ); +isBigInteger = x.times( "100" ); isNumber = x.toJSNumber(); diff --git a/bigInteger/bigInteger.d.ts b/bigInteger/bigInteger.d.ts index ed03fc5ea..a98fad7e7 100644 --- a/bigInteger/bigInteger.d.ts +++ b/bigInteger/bigInteger.d.ts @@ -11,46 +11,64 @@ interface BigInteger { add( number: number ): BigInteger; /** Performs addition */ add( number: BigInteger ): BigInteger; + /** Performs addition */ + add( number: string ): BigInteger; /** Alias for the add method. */ plus( number: number ): BigInteger; /** Alias for the add method. */ plus( number: BigInteger ): BigInteger; + /** Alias for the add method. */ + plus( number: string ): BigInteger; /** Alias for the subtract method. */ minus( number: number ): BigInteger; /** Alias for the subtract method. */ minus( number: BigInteger ): BigInteger; + /** Alias for the subtract method. */ + minus( number: string ): BigInteger; /** Performs subtraction. */ subtract( number: number ): BigInteger; /** Performs subtraction. */ subtract( number: BigInteger ): BigInteger; + /** Performs subtraction. */ + subtract( number: string ): BigInteger; /** Performs multiplication. */ multiply( number: number ): BigInteger; /** Performs multiplication. */ multiply( number: BigInteger ): BigInteger; + /** Performs multiplication. */ + multiply( number: string ): BigInteger; /** Alias for the multiply method. */ times( number: number ): BigInteger; /** Alias for the multiply method. */ times( number: BigInteger ): BigInteger; + /** Alias for the multiply method. */ + times( number: string ): BigInteger; /** Performs integer division, disregarding the remainder. */ divide( number: number ): BigInteger; /** Performs integer division, disregarding the remainder. */ divide( number: BigInteger ): BigInteger; + /** Performs integer division, disregarding the remainder. */ + divide( number: string ): BigInteger; /** Alias for the divide method. */ over( number: number ): BigInteger; /** Alias for the divide method. */ over( number: BigInteger ): BigInteger; + /** Alias for the divide method. */ + over( number: string ): BigInteger; /** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */ pow( number: number ): BigInteger; /** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */ pow( number: BigInteger ): BigInteger; + /** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */ + pow( number: string ): BigInteger; /** Adds one to the number. */ next(): BigInteger; @@ -62,31 +80,43 @@ interface BigInteger { mod( number: number ): BigInteger; /** Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend. */ mod( number: BigInteger ): BigInteger; + /** Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend. */ + mod( number: string ): BigInteger; /** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */ divmod( number: number ): { quotient: BigInteger; remainder: BigInteger }; /** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */ divmod( number: BigInteger ): { quotient: BigInteger; remainder: BigInteger }; + /** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */ + divmod( number: string ): { quotient: BigInteger; remainder: BigInteger }; /** Checks if the first number is greater than the second. */ greater( number: number ): boolean; /** Checks if the first number is greater than the second. */ greater( number: BigInteger ): boolean; + /** Checks if the first number is greater than the second. */ + greater( number: string ): boolean; /** Checks if the first number is greater than or equal to the second. */ greaterOrEquals( number: number ): boolean; /** Checks if the first number is greater than or equal to the second. */ greaterOrEquals( number: BigInteger ): boolean; + /** Checks if the first number is greater than or equal to the second. */ + greaterOrEquals( number: string ): boolean; /** Checks if the first number is lesser than the second. */ lesser( number: number ): boolean; /** Checks if the first number is lesser than the second. */ lesser( number: BigInteger ): boolean; + /** Checks if the first number is lesser than the second. */ + lesser( number: string ): boolean; /** Checks if the first number is less than or equal to the second. */ lesserOrEquals( number: number ): boolean; /** Checks if the first number is less than or equal to the second. */ lesserOrEquals( number: BigInteger ): boolean; + /** Checks if the first number is less than or equal to the second. */ + lesserOrEquals( number: string ): boolean; /** Returns true if the number is even, false otherwise. */ isEven(): boolean; @@ -110,21 +140,32 @@ interface BigInteger { * If the first number is greater, it returns 1. If the first number is lesser, it returns -1. */ compare( number: BigInteger ): BigInteger; + /** + * Performs a comparison between two numbers. If the numbers are equal, it returns 0. + * If the first number is greater, it returns 1. If the first number is lesser, it returns -1. + */ + compare( number: string ): BigInteger; /** Performs a comparison between the absolute value of two numbers. */ compareAbs( number: number ): BigInteger; /** Performs a comparison between the absolute value of two numbers. */ compareAbs( number: BigInteger ): BigInteger; + /** Performs a comparison between the absolute value of two numbers. */ + compareAbs( number: string ): BigInteger; /** Checks if two numbers are equal. */ equals( number: number ): boolean; /** Checks if two numbers are equal. */ equals( number: BigInteger ): boolean; + /** Checks if two numbers are equal. */ + equals( number: string ): boolean; /** Checks if two numbers are not equal. */ notEquals( number: number ): boolean; /** Checks if two numbers are not equal. */ notEquals( number: BigInteger ): boolean; + /** Checks if two numbers are not equal. */ + notEquals( number: string ): boolean; /** Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range. */ toJSNumber(): number;