Difference between revisions of "$calc"

From Scriptwiki
Jump to: navigation, search
 
(a)
Line 24: Line 24:
 
  echo -a $calc([[$len]]([[$me]]) * (2 ^ %x % 3) - ([[$ticks]] / (10000 + 1)))
 
  echo -a $calc([[$len]]([[$me]]) * (2 ^ %x % 3) - ([[$ticks]] / (10000 + 1)))
 
  ; returns numeric value depending of $ticks's value and $me's length
 
  ; returns numeric value depending of $ticks's value and $me's length
 +
 +
{{Author|Tovrleaf}}
  
 
[[Category:Text_and_Number_Identifiers]]
 
[[Category:Text_and_Number_Identifiers]]

Revision as of 18:05, 31 August 2005

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 1
$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