$calc: Difference between revisions

From Scriptwiki
Jump to navigation Jump to search
Tovrleaf (talk | contribs)
No edit summary
 
m fixed 1 + 1+ = 2
 
(One intermediate revision by one other user not shown)
Line 16: Line 16:


  $calc(1 + 1)
  $calc(1 + 1)
  ; returns 1
  ; returns 2
  $calc(5 % 2)
  $calc(5 % 2)
  ; returns 1
  ; returns 1
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]]

Latest revision as of 21: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