Name

div

Synopsis

integer division

integer division

Syntax

number1 div number2

Description

Obtains the integer part of a division. Both numbers are treated as reals; the first is divided by the second, and the result is coerced to an integer by throwing away its fractional part. Notice that this is not the same as AppleScript's normal real-to-integer coercion behavior. Thus, the way to get the integer part of a real in AppleScript is x div 1, not x as integer.

Example

4 div 5 -- 0
(4 / 5) as integer -- 1

Get AppleScript: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.