Number

Extends Literal. EV Script has one type of number.

Methods
abs()

Returns Number

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


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

Returns 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
asin()

Returns 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
atan()

Returns 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
ceil()

Returns Number

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


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

Returns Number

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


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

Returns 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()

Returns 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([Number:precision [, String:decimal [, String:thousand]]])

Returns 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 (,). 


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

Returns 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)

Returns 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])

Returns 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
sin()

Returns Number

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


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

Returns 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()

Returns Number

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


var num = 0.52;
print(num.tan()); // 0.57
toMoney([String:isoCode])

Returns 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
wrap(String:tag)

Returns 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>