Division and Modulus for Computer Scientists (2003)
The document reviews various definitions of division and modulus functions in programming, including truncated, floored, and Euclidean division, providing an algorithm and proof of correctness for Euclidean division.
Read original articleThe document discusses various definitions of division and modulus functions in programming languages, focusing on the common and less common approaches. It reviews truncated division, Knuth’s floored division, and the mathematically elegant Euclidean division. The author, Daan Leijen, provides an algorithm for the Euclidean division and modulus functions, along with a proof of its correctness based on Euclid’s theorem. This exploration highlights the diversity in how division is implemented across different programming languages and the theoretical underpinnings that support these definitions.
- The document reviews multiple definitions of division and modulus in programming.
- It discusses common methods like truncated and floored division, as well as Euclidean division.
- An algorithm for Euclidean division and modulus is provided, with a proof of correctness.
- The work emphasizes the theoretical foundations of division in computer science.
Related
Identifying Leap Years (2020)
David Turner explores optimizing leap year calculations for performance gains by using bitwise operations and integer bounds. He presents efficient methods, mathematical proofs, and considerations for signed integers, highlighting limitations pre-Gregorian calendar.
Check Maybe Div by Zero for Gleam
check_maybe_div_by_zero is a Gleam tool that detects potential division by zero in code, ensuring expected behavior. It integrates with CI systems and supports multiple targets, enhancing code quality.
Lisp's Grandfather Paradox
The article explores primitive recursion's historical context, key contributors, foundational functions, limitations, and implications in programming languages, emphasizing experiential learning and philosophical connections to Lisp.
Crafting Formulas: Lambdas All the Way Down
The article details arbitrary-precision arithmetic in the Bruijn programming language, focusing on integers, rationals, and the challenges of real numbers, while discussing efficient representations and computational complexities.
Floating Point Math
Floating point math in computing can cause inaccuracies in decimal calculations due to binary representation limitations. Different programming languages manage this with varying precision, affecting results like 0.1 + 0.2.
Related
Identifying Leap Years (2020)
David Turner explores optimizing leap year calculations for performance gains by using bitwise operations and integer bounds. He presents efficient methods, mathematical proofs, and considerations for signed integers, highlighting limitations pre-Gregorian calendar.
Check Maybe Div by Zero for Gleam
check_maybe_div_by_zero is a Gleam tool that detects potential division by zero in code, ensuring expected behavior. It integrates with CI systems and supports multiple targets, enhancing code quality.
Lisp's Grandfather Paradox
The article explores primitive recursion's historical context, key contributors, foundational functions, limitations, and implications in programming languages, emphasizing experiential learning and philosophical connections to Lisp.
Crafting Formulas: Lambdas All the Way Down
The article details arbitrary-precision arithmetic in the Bruijn programming language, focusing on integers, rationals, and the challenges of real numbers, while discussing efficient representations and computational complexities.
Floating Point Math
Floating point math in computing can cause inaccuracies in decimal calculations due to binary representation limitations. Different programming languages manage this with varying precision, affecting results like 0.1 + 0.2.