INTDIV(3am) GNU Awk Extension Modules INTDIV(3am)

# [NAME](#NAME)

intdiv - perform integer division in one operation

# [SYNOPSIS](#SYNOPSIS)

@load "intdiv"

success = intdiv(numerator, denominator, result)

# [DESCRIPTION](#DESCRIPTION)

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

[**intdiv(numerator, denominator, result)**](#intdiv%28)

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](#SEE_ALSO)

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

[*div*(3)](/man/os/gawk/div.3).

# [AUTHOR](#AUTHOR)

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

# [COPYING PERMISSIONS](#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.

Apr 15 2026 Free Software Foundation

---

Document: intdiv(3am) from gawk 5.4.1-r4 (Chainguard OS)
Source: https://git.savannah.gnu.org/git/gawk.git
