Old school Swatch Watches
/ /

XtScript: Arithmetic Operators

How to use math operators in XtScript

Basic Arithmetic operator in XtScript work just the same way in Javscript or PHP.

Except that in XtScript, the math operation must be done inside a brackets ()

Basic Arithmetic Operator
SymbolName
+Addition
-Subtraction
*Multiplication
/Division
%Modulus

Learn Math operation in XtScript from examples

Math operation examples

- Code:
<!--parser:xtscript-->
	var $hundred = 100
	var $ten = 10

	var $add = ($hundred + $ten)
	var $min = ($hundred - $ten)
	var $mult = ($hundred * $ten)
	var $div = ($hundred / $ten)
	var $mod = ($hundred % $ten)
	var $multi = ($hundred * $ten / 4 + 1)

	print The math results of differents operator of <b>$hundred</b> and <b>$ten</b>:<br/>
	print $hundred + $ten = $add <br/>
	print $hundred - $ten = $min <br/>
	print $hundred * $ten = $mult <br/>
	print $hundred / $ten = $div <br/>
	print $hundred % $ten = $mod <br/><br/>

	print Multiple math operation hold principle to basic math operation sequence \(* -> / -> + -> - ): <br/>
	print $hundred * $ten / 4 + 1 = $multi <br/><br/>

	print Or we can use math operator directly in print command:<br/>
	print $hundred : 4 = ($hundred / 4)
<!--/parser:xtscript-->
- Result:
The math results of differents operator of 100 and 10:
100 + 10 = 110
100 - 10 = 90
100 * 10 = 1000
100 / 10 = 10
100 % 10 = 0

Multiple math operation hold principle to basic math operation sequence (* -> / -> + -> - ):
100 * 10 / 4 + 1 = 251

Or we can use math operator directly in print command:
100 : 4 = 25