INTDIV(3am)
π INTDIV(3am) π
okay bestie, welcome to the GNU Awk Extension Modules corner of the manual, this is intdiv and she is so good at her one job π«Ά
β¨ NAME β¨
intdiv β perform integer division in one operation π
πΈ SYNOPSIS πΈ
@load "intdiv"
success = intdiv(numerator, denominator, result)
π¦ DESCRIPTION π¦
The intdiv extension ships exactly one function, and that function does integer division β like the standard C div() function but living in your awk, periodt. π₯
π intdiv(numerator, denominator, result)
okay so here's the whole vibe, step by step:
- First it truncates numerator and denominator toward zero, making them integer values. no decimals allowed at this party π
- Then it clears the result array. fresh slate, clean girl energy β¨
- Then it sets
result["quotient"]to the result ofnumerator / denominator, truncated toward zero to an integer. - And it sets
result["remainder"]to the result ofnumerator % denominator, truncated toward zero to an integer.
π¨ not me warning you: attempting division by zero causes a fatal error. like, the whole thing dies. no cap. π
The function returns zero upon success, and -1 upon error. that's it, that's the deal π
lowkey the whole reason she exists: this function is useful primarily with GMP arbitrary length integers, because it avoids creating MPFR arbitrary precision floating-point values. iykyk π§
π SEE ALSO π
- GAWK: Effective AWK Programming, and the man pages for the other extensions shipped with
gawk. div(3).
π 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.
and that's the whole page bestie, mwah π β this one's brought to you by the Free Software Foundation, dated Apr 15 2026, filed under INTDIV(3am) π¦β¨ go forth and divide integers, you main character π«Ά
π¦ where this page comes from
- arch rolling: gawk 5.4.1-1 Β· GPL-3.0-or-later
- nixos 26.05: gawk-interactive 5.4.1
- nixpkgs unstable: gawk 5.4.1
- nixpkgs unstable: gawk-interactive 5.4.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms