Converts string into bigDecimal.
In JavaScript, integers larger than 10^22 and the decimal values smaller than 10^(-7) are force-converted into exponential, and values after 15th decimal points are discarded.
To complement this, converts string into bigDecimal.
WebSquare.bigDecimal.calc receives the expression in the string type and conducts bigDecimal operation.
In order to use bigDecimal, add <module src="externalJS/big/big.min.js"/> to the engine node of config.xml.
Type
- engine
Property Summary
Event Summary
Method Summary
- ( bigStr )
- Converts string into bigDecimal.
- calc( str )
- Conducts calculations written in string in bigDecimal type.
- compare( data , type )
- If the type is "true", returns the smaller number compared with the received bigDecimal data.
- divide( bigDecimal )
- Divides the bigDecimal data.
- minus( bigDecimal )
- Subtracts the bigDecimal data.
- mod( bigDecimal )
- Conduct modulus operation on the bigDecimal data.
- plus( bigDecimal )
- Adds bigDecimal data.
- pow( bigDecimal )
- Squares the bigDecimal data.
- times( bigDecimal )
- Multiplies the bigDecimal data.
Property Detail
Event Detail
Method Detail
- ( bigStr )
-
Converts string into bigDecimal.
Do not enter numeric data in number type. Input the data in string format.Parameter name type required description bigStr String Y Numeric data written in string format Return type description Object bigDecimal data Samplevar a = WebSquare.bigDecimal("123456789012345678901234567890"); //a : 30-digit numeric bigDecimal data var b = WebSquare.bigDecimal(123456789012345678901234567890); //Wrong parameter. Input the data in the string format. - calc( str )
-
Conducts calculations written in string in bigDecimal type. However, in SP4 or higher versions, use scwin.$w.bigDecimal.calc() format.
Parameter name type required description str String Y Expression in string format Return type description Object Returns the result in bigDecimal. Sample// (Example 1) var a = scwin.$w.bigDecimal("123456789012345678901234567890"); var b = scwin.$w.bigDecimal("111111111111111111111111111111"); var c = scwin.$w.bigDecimal("678901234567890123456789012345"); var d = scwin.$w.bigDecimal("345678934567893456789345678934"); var ret = WebSquare.bigDecimal.calc("a + b c + (d - a) / (c + d)"); input1.setValue(ret); // The calculation result will be displayed in input1. // (Example 2) var a = scwin.$w.bigDecimal("1234"); var b = 3000; var ret = scwin.$w.bigDecimal.calc ("a+b*b-b/(a+b)"); // Number + bigDecimal calculation is possible. The number must be in 17-digit. // (Example 3) var a = "abcd"; // NaN var b = scwin.$w.bigDecimal("200"); var ret = scwin.$w.bigDecimal.calc("a + b"); input2.setValue(ret); // The calculation result is the bigDecimal for NaN data. Calculation with non-numeric data will result in NaN data. - compare( data , type )
-
If the type is "true", returns the smaller number compared with the received bigDecimal data.
If the type is "false" or undefined, returns the larger number compared with the received bigDecial data.Parameter name type required description data Object Y bigDecimal data to compare type Boolean N Comparison method (true - Returns the bigger number. false - Returns the smaller number.) Return type description Object Returns the smaller number compared with the received bigDecimal data. Sample// Get the largest value. var a = WebSquare.bigDecimal("111111111111111111111111111111"); var b = WebSquare.bigDecimal("11111"); var result = a.compare(b); var result = a.compare(b,false); var result = a.compare(b,0); result = WebSquare.bigDecimal("111111111111111111111111111111"); // Get the smallest value. var a = WebSquare.bigDecimal("111111111111111111111111111111"); var b = WebSquare.bigDecimal("11111"); var result = a.compare(b,true); var result = a.compare(b,1); result = WebSquare.bigDecimal("11111"); - divide( bigDecimal )
-
Divides the bigDecimal data.
Parameter name type required description bigDecimal Object Y bigDecimal data to divide Return type description Object Division result in bigDecimal format Samplevar a = WebSquare.bigDecimal("111111111111111"); var b = WebSquare.bigDecimal("222222222222222"); var c = WebSquare.bigDecimal("0"); var result = a.divide(b); var result2 = a.divide(c); // If divide by 0, bigDecimal data for NAN will be returned. - minus( bigDecimal )
-
Subtracts the bigDecimal data.
Parameter name type required description bigDecimal Object Y bigDecimal data to subtract Return type description Object Result of subtraction on the bigDecimal data Samplevar a = WebSquare.bigDecimal("111111111111111"); var b = WebSquare.bigDecimal("222222222222222"); var result = a.minus(b); - mod( bigDecimal )
-
Conduct modulus operation on the bigDecimal data.
Parameter name type required description bigDecimal Object Y bigDecimal data to conduct modulus operation. Return type description Object Result of modulus in bigDecimal format Samplevar a = WebSquare.bigDecimal("111111111111111111111111111111"); var b = WebSquare.bigDecimal("11111"); var result = a.mod(b); - plus( bigDecimal )
-
Adds bigDecimal data.
Parameter name type required description bigDecimal Object Y bigDecimal to add Return type description Object Result of the Add function in bigDecimal format Samplevar a = WebSquare.bigDecimal("111111111111111"); var b = WebSquare.bigDecimal("222222222222222"); var result = a.plus(b); - pow( bigDecimal )
-
Squares the bigDecimal data.
Parameter name type required description bigDecimal Object Y bigDecimal data to square Return type description Object Result of squaring in bigDecimal type Samplevar a = WebSquare.bigDecimal("11111"); var b = WebSquare.bigDecimal("5"); var result = a.pow(b); // It may take long to square a high-digit number. - times( bigDecimal )
-
Multiplies the bigDecimal data.
Parameter name type required description bigDecimal Object Y bigDecimal data to multiply Return type description Object Result of multiplication in bigDecimal format Samplevar a = WebSquare.bigDecimal("111111111111111"); var b = WebSquare.bigDecimal("222222222222222"); var result = a.times(b);