diff options
Diffstat (limited to 'chapters/pseudocode.adoc')
-rw-r--r-- | chapters/pseudocode.adoc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/chapters/pseudocode.adoc b/chapters/pseudocode.adoc index 55c35d4..d674c9c 100644 --- a/chapters/pseudocode.adoc +++ b/chapters/pseudocode.adoc @@ -477,6 +477,16 @@ int32_t idiv_check(int32_t input1, int32_t input2) { return input1 / input2; // exact quotient without rounding } +// perform an integer division with rounding towards minus infinity + +int32_t idiv_floor(int32_t input1, int32_t input2) { + int32_t rval = input1 / input2; + if (rval * input2 > input1) { + rval--; + } + return rval; +} + int32_t length(in_t input) return number of elements in input list |