Difference between revisions of "$calc"

From Scriptwiki
Jump to: navigation, search
(a)
m (fixed 1 + 1+ = 2)
 
Line 16: Line 16:
  
 
  $calc(1 + 1)
 
  $calc(1 + 1)
  ; returns 1
+
  ; returns 2
 
  $calc(5 % 2)
 
  $calc(5 % 2)
 
  ; returns 1
 
  ; returns 1

Latest revision as of 22:28, 4 December 2006

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