$calc

From Scriptwiki
Jump to: navigation, search

Returns the result of the specified operations. This identifiers allows you to perform multiple operations easily. For example:

$calc(operations)

Possible operator are:

+ plus
- minus
/ division
* multiplication
^ potency
% remainder

Operations can only consist of possible operators and numeral tokens, including integer- and desicalnumers but also variables and identifiers holding numeric value.

Examples

$calc(1 + 1)
; returns 2
$calc(5 % 2)
; returns 1
$calc($ctime ^ $pi)
; returns numeric value depending of $ctime's value
var %x = 123
echo -a $calc($len($me) * (2 ^ %x % 3) - ($ticks / (10000 + 1)))
; returns numeric value depending of $ticks's value and $me's length
Contributed by Tovrleaf