INTDIV(3am)

πŸ“¦ version 5.4.1, in arch rolling, nixos 26.05, nixpkgs unstable

πŸ’– 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 of numerator / denominator, truncated toward zero to an integer.
  • And it sets result["remainder"] to the result of numerator % 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