---
name: "intdiv"
section: "3am"
platform: "linux"
package: "gawk"
version: "5.4.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/intdiv"
---

# intdiv(3am)

perform integer division in one operation

## NAME

intdiv - perform integer division in one operation

## SYNOPSIS

`@load "intdiv"`

`success = intdiv(numerator, denominator, result)`

## DESCRIPTION

The *intdiv* extension provides a single function that performs integer division, similar to the standard C `div()` function.

- **intdiv(***numerator***,** *denominator***,** *result***)**

  First, truncate *numerator* and *denominator* towards zero, creating integer values.  Clear the  *result* array, and then set **result\["quotient"\]** to the result of *numerator / denominator*, truncated towards zero to an integer, and set **result\["remainder"\]** to the result of *numerator % denominator*, truncated towards zero to an integer. Attempting division by zero causes a fatal error. The function returns zero upon success, and -1 upon error.

This function is useful primarily with GMP arbitrary length integers; it avoids creating MPFR arbitrary precision floating-point values.

## SEE ALSO

*GAWK: Effective AWK Programming*, and the man pages for the other extensions shipped with *gawk*.

[*div*(3)](/div/3.md).

## AUTHOR

Arnold Robbins, **arnold@skeeve.com**.

## COPYING PERMISSIONS

Copyright © 2026, Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of this manual page provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.
