Share on Facebook Tweet on Twitter Share on LinkedIn Share by email
Division and Modulus for Computer Scientists

Daan Leijen


There exist many definitions of the div and mod functions in computer science literature and programming languages. We briefly review the most common definitions (truncated division, Knuth's floored division, etc.) and discuss the rare, but mathematically elegant, Euclidean division. We also give an algorithm for the Euclidean div and mod functions and prove it correct with respect to Euclid's theorem.


Publication typeMiscellaneous
Book titleShort note about division definitions in programming languages
> Publications > Division and Modulus for Computer Scientists