PropertyEventMethodIndex
WebSquare.bigDecimal - 5.0_4.4547B.20211124.201933

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
nametyperequireddescription
bigStrStringYNumeric data written in string format
Return
typedescription
ObjectbigDecimal data
Sample
var 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
nametyperequireddescription
strStringYExpression in string format
Return
typedescription
ObjectReturns 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
nametyperequireddescription
dataObjectYbigDecimal data to compare
typeBooleanNComparison method (true - Returns the bigger number. false - Returns the smaller number.)
Return
typedescription
ObjectReturns 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
nametyperequireddescription
bigDecimalObjectYbigDecimal data to divide
Return
typedescription
ObjectDivision result in bigDecimal format
Sample
var 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
nametyperequireddescription
bigDecimalObjectYbigDecimal data to subtract
Return
typedescription
ObjectResult of subtraction on the bigDecimal data
Sample
var a = WebSquare.bigDecimal("111111111111111"); var b = WebSquare.bigDecimal("222222222222222"); var result = a.minus(b);
mod( bigDecimal )
Conduct modulus operation on the bigDecimal data.
Parameter
nametyperequireddescription
bigDecimalObjectYbigDecimal data to conduct modulus operation.
Return
typedescription
ObjectResult of modulus in bigDecimal format
Sample
var a = WebSquare.bigDecimal("111111111111111111111111111111"); var b = WebSquare.bigDecimal("11111"); var result = a.mod(b);
plus( bigDecimal )
Adds bigDecimal data.
Parameter
nametyperequireddescription
bigDecimalObjectYbigDecimal to add
Return
typedescription
ObjectResult of the Add function in bigDecimal format
Sample
var a = WebSquare.bigDecimal("111111111111111"); var b = WebSquare.bigDecimal("222222222222222"); var result = a.plus(b);
pow( bigDecimal )
Squares the bigDecimal data.
Parameter
nametyperequireddescription
bigDecimalObjectYbigDecimal data to square
Return
typedescription
ObjectResult of squaring in bigDecimal type
Sample
var 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
nametyperequireddescription
bigDecimalObjectYbigDecimal data to multiply
Return
typedescription
ObjectResult of multiplication in bigDecimal format
Sample
var a = WebSquare.bigDecimal("111111111111111"); var b = WebSquare.bigDecimal("222222222222222"); var result = a.times(b);