Number

Extends Literal. EV Script has one type of number.

Methods
abs() Number

Returns the absolute unsigned value of a number leaving the original Number unmutated.


var num = -1234.1;
print(num.abs()); // 1234.1
acos() Number

Returns the arc cosine of the original Number in radians leaving the original Number unmutated.


var num = 0.52;
print(num.acos()); // 1.02
acosh() Number

Returns the hyperbolic arc-cosine of the number.


var num = 2.5;
print(num.acosh()); // 1.5667992369724
asin() Number

Returns the arc sine of the original Number in radians leaving the original Number unmutated.


var num = 0.52;
print(num.asin()); // 0.55
asinh() Number

Returns the hyperbolic arcsine of the number.


var num = 2;
print(num.asinh()); // 1.4436354751788
atan() Number

Returns the arc tan of the original Number in radians leaving the original Number unmutated.


var num = 0.52;
print(num.atan()); // 0.48
atanh() Number

Returns the hyperbolic arctangent of the number.


var num = 0.5;
print(num.atanh()); // 0.54930614433405
ceil() Number

Returns a new Number rounded up to the nearest integer leaving the original Number unmutated.


var num = 1234.1;
print(num.ceil()); // 1235
cbrt() Number

Returns the cube root of a number.

cos() Number

Returns the cosine of the original Number in radians leaving the original Number unmutated.


var num = 0.52;
print(num.cos()); // 0.87
cosh() Number

Returns hyperbolic cosine of a number.

decimal([precision = 2]) String

Returns the number as a string to the precision requested (defaults to 2 decimal places).

decimalPlaces() Number

Returns the number of decimal places of found in the value.

exp() Number

Returns the exponent of 'e' (approx. 2.718282) raised to the power of the original Number as a new Number leaving the original Number unmutated.


var num = 5.7;
print(num.exp()); // 298.87
floor() Number

Returns a new Number rounded down to the nearest integer leaving the original Number unmutated.


var num = 1234.7;
print(num.ceil()); // 1234
format([precision [, decimal [, thousand]]]) String

A fixed format for the Number value. Since Evance is primarily an ecommerce platform the default value for precision is 2 decimal places, the default decimal value is a dot (.) and the default thousand point is a comma (,). 

Parameters

precision Number
Optional. The number of decimal places to render. Defaults to 2.

decimal String
Optional. Decimal place character. Defaults to ..

thousand String
Optiona. Thousand place separator. Defaults to a ,.


var num = 1234;
print(num.format()); // 1,234.00
print(num.format(0)); // 1,234
isInteger() Boolean

Returns true if the rounded number mathces its integer value. For this reason a value of 1.0 is considered an integer.

isNegative() Boolean

Returns true if the number is below 0, or falseif the number is great than or equal to 0.

isPositive() Boolean

Returns true if the number is greater than or equal to 0, or false if the number is less than 0.

isZero() Boolean

Returns true if the number is equal to 0, or false otherwise.

log() Number

Returns the natural logarithm of the original number as a new Number leaving the original unmutated.


var num = 10;
print(num.log()); // 2.30
pow(Number:exponent) Number

Returns the original number raised to the power of the exponent as a new Number leaving the original unmutated.


var num = 7;
print(num.pow(2)); // 49
round([Number:precision]) Number

Returns the current number to the supplied decimal precision as a new number. Since Evance is primarily an ecommerce platform the default precision is 2 decimal places.


var num = 1234.567;
print(num.round()); // 1234.57
print(num.round(0)); // 1235
sign() Number

Returns either a positive or negative +/- 1, indicating the sign of the number. If the number is 0, it will return a +/- 0.

sin() Number

Returns the sine of the original Number in radians leaving the original Number unmutated.


var num = 0.52;
print(num.sin()); // 0.50
sinh() Number

Returns the hyperbolic sine of the Number.

sqrt() Number

Returns the square root of the original Number as new Number leaving the original Number unmutated.


var num = 49;
print(num.sqrt()); // 7
tan() Number

Returns the tan of the original Number in radians leaving the original Number unmutated.


var num = 0.52;
print(num.tan()); // 0.57
tanh() Number

Returns the hyperbolic tangent of the Number.

toMoney([String:isoCode]) Money

Returns a new Money object with the current Number as the decimal value. If a currency isoCode is not supplied the currency used is that of the current locale. You can explicitly set the currency by supplying a valid currency ISO Code e.g. GBP or USD.


var num = 1;
print(num.toMoney()); // £1.00 if the current locale's currency is GBP
print(num.toMoney('USD')); // $1.00
toPrecision() String

Returns a string representing the Number object to the specified precision.

trunc() Number

Returns the integer part of a number by removing any fractional digits.

wrap(String:tag) String

Allows you to wrap a number with any valid HTML tag and returns the resulting String


var num = 1;
print(num.wrap('<p/>')); // <p>1</p>