aboutsummaryrefslogtreecommitdiff
path: root/chapters/pseudocode.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'chapters/pseudocode.adoc')
-rw-r--r--chapters/pseudocode.adoc7
1 files changed, 7 insertions, 0 deletions
diff --git a/chapters/pseudocode.adoc b/chapters/pseudocode.adoc
index 238aa33..3f885c7 100644
--- a/chapters/pseudocode.adoc
+++ b/chapters/pseudocode.adoc
@@ -185,6 +185,13 @@ int idiv(int input1, int input2) {
return input1 / input2; // Integer divide that truncates towards zero
}
+// Integer division that checks input1 is a multiple of input2
+
+int idiv_check(int input1, int input2) {
+ ERROR_IF(input1 % input2 != 0); // input1 must be a multiple of input2
+ return input1 / input2; // exact quotient without rounding
+}
+
int length(in_t input)
return number of elements in input list