EasyManua.ls Logo

MACROMEDIA DIRECTOR MX 2004-DIRECTOR SCRIPTING - Page 597

MACROMEDIA DIRECTOR MX 2004-DIRECTOR SCRIPTING
1130 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
- (minus) 597
- (minus)
Usage
-- Lingo syntax
(Negation): -expression
(Subtraction): expression1 - expression2
// JavaScript syntax
(Negation): -expression
(Subtraction): expression1 - expression2
Description
Math operator; when used for negation, - (minus) reverses the sign of the value of expression;
when used for subtraction, - (minus) performs an arithmetic subtraction on two numerical
expressions, subtracting
expression2 from expression1.
When used for negation, - (minus) is an arithmetic operator with a precedence level of 5.
When used for subtraction, both expressions are integers, the difference is an integer. When either
or both expressions are floating-point numbers, the difference is a floating-point number. The
- (minus) operator is an arithmetic operator with a precedence level of 3.
Example
(Negation): This statement reverses the sign of the expression 2 + 3:
-- Lingo syntax
put(-(2 + 3))
// JavaScript syntax
put(-(2 + 3));
The result is -5.
(Subtraction)
: This statement subtracts the integer 2 from the integer 5 and displays the result in
the Message window:
-- Lingo syntax
put(5 - 2)
// JavaScript syntax
put(5 - 2);
The result is 3, which is an integer.
(Subtraction): This statement subtracts the floating-point number 1.5 from the floating-point
number 3.25 and displays the result in the Message window:
-- Lingo syntax
put(3.25 - 1.5)
// JavaScript syntax
put(3.25 - 1.5);
The result is 1.75, which is a floating-point number.