O'Reilly logo

AppleScript® Programming for the Absolute Beginner by Jerry Lee Ford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Analyzing Mathematical Expressions

AppleScript provides a range of arithmetic operators that you can use to build mathematical expressions, whose results you can then analyze and use to control the logical execution of statements within your AppleScripts. The arithmetic operators supported by AppleScript are demonstrated in Table 4.2.

Table 4.2. Arithmetic Operators
OperatorDescription ExampleResult 
+Additionx = 5 + 510
Subtractionx = 10 – 55
*Multiplicationx = 10 * 550
/Division (Option /)x = 10 / 1.059.52380952381
^Exponentiationx = 5 ^ 225
divInteger division with the result returned as a non-rounded integerx = 10 div 1.059
modInteger division with the remainder returned as an integerx = 10 mod 1.05.55

Hint

If you prefer, you may substitute ÷ for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required