aboutsummaryrefslogtreecommitdiff
path: root/chapters/pseudocode.adoc
diff options
context:
space:
mode:
authorEric Kunze <eric.kunze@arm.com>2023-08-31 16:14:05 -0700
committerEric Kunze <eric.kunze@arm.com>2023-09-11 21:59:25 +0000
commitfe2ac6d7b9cbc7de4befa128a1ac514712030e74 (patch)
tree98d36e9c39a4aa2986dbbb3d71b10ff744bf1a3b /chapters/pseudocode.adoc
parentb203512ca3583fd0968ea281aedec2a840b6e58b (diff)
downloadspecification-fe2ac6d7b9cbc7de4befa128a1ac514712030e74.tar.gz
Add integer divide with floor for coordinate calculation
Define idiv_floor to give equivalent behavior to the floating-point floor function for image coordinate calculation. Change-Id: Id6268794b1e3ce5cc1114bda74dd06b892457a8e Signed-off-by: Eric Kunze <eric.kunze@arm.com>
Diffstat (limited to 'chapters/pseudocode.adoc')
-rw-r--r--chapters/pseudocode.adoc10
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