division

Quotient Division

The slash symbol can be used as the division operator to produce the result of a quotient division calculation of two [[operand?]]s:

answer = 18 / 3 # 6

Division Combination Assignment Operator

The division [[combination_assignment_operator?]] represented by a [[climbequal?]]s digraph, can also be used to perform a quotient division calculation:

value /= 3 # value = value / 3

Integer Division

The awk programming language does not support the use of a backslash symbol as an integer division operator. However, the [[int?]] function can be used to produce [[integer?]] results from a mathematical quotient:

BEGIN { print int(22 / 6) }

Division by zero

Traditional Unix behaviour is to abort awk with a fatal error, if a division by zero is encountered.

mawk

The mawk interpreter does not abort with a fatal error if a division by zero is encountered. Instead mawk returns an inf string without producing a warning or error:

  1. This will cause a fatal error in traditional awk implementations BEGIN { print 3 / 0 # inf }