summaryrefslogtreecommitdiff
path: root/digital/avr/modules/math/geometry/intersection.c
diff options
context:
space:
mode:
Diffstat (limited to 'digital/avr/modules/math/geometry/intersection.c')
-rw-r--r--digital/avr/modules/math/geometry/intersection.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/digital/avr/modules/math/geometry/intersection.c b/digital/avr/modules/math/geometry/intersection.c
index 1f8a9278..a1daf72d 100644
--- a/digital/avr/modules/math/geometry/intersection.c
+++ b/digital/avr/modules/math/geometry/intersection.c
@@ -25,18 +25,21 @@
#include "common.h"
#include "intersection.h"
-/** Compare a and b to determine if a / b is in [0:1]. Return non zero if
+/** Compare a and b to determine if a / b is in ]0:1[. Return non zero if
* true. */
static uint8_t
intersection_div_is_in_0_1 (int32_t a, int32_t b)
{
+ assert (b != 0);
/* Test sign, a / b < 0 if different. */
- if ((a >> 31) ^ (b >> 31))
+ if ((a ^ b) & 0x80000000)
+ return 0;
+ else if (a == 0)
return 0;
else if (a > 0)
- return a <= b;
+ return a < b;
else
- return a >= b;
+ return a > b;
}
uint8_t