Skip to main content

slash

Type

operator

Summary

Divides one number by another number or one array by another array.

Syntax

<dividend> / <divisor>

Description

Use the / (divide) operator to divide one number by another.

note

When used in complex arithmetic statements, operators like / follows standard rules of precedence.

To divide the contents of a container by a number, use the divide command instead.

If dividend or divisor is an array, each of the array elements must be a number. If an array is divided by a number, each element is divided by the number. If an array is divided by an array, both arrays must have the same number of elements and the same dimension, and each element in one array is divided by the corresponding element of the other array.

If an element of an array is empty, the / operator treats its contents as zero.

If a math operation on finite inputs produces a non-finite output, an execution error is thrown. See math operations for more information.

Parameters

NameTypeDescription

dividend

A number or an expression that evaluates to a number, or an array containing numbers.

divisor

A number or an expression that evaluates to a number, or an array containing numbers.

Examples

# Dividing a literal number by another
local approxPi
put 22/7 into approxPi -- approximates pi
# Dividing two variables
local thisVariable
get thisVariable/(thisVariable + 1)
# Dividing an array by another
local tNumberArray, tDivisorArray, tDividedArray
put 10 into tNumberArray[1]
put 20 into tNumberArray[2]
put 10 into tDivisorArray[1]
put 5 into tDivisorArray[2]
put tNumberArray / tDivisorArray into tDividedArray
put tDividedArray[1] & comma & tDividedArray[2]
# Yields 1,4

command: divide

glossary: operator, array, command, element, precedence, math operation

keyword: element

operator: div, mod, asterisk, wrap

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

web

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?