aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/ternary/ternary.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/monniaux/ternary/ternary.c')
-rw-r--r--test/monniaux/ternary/ternary.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/monniaux/ternary/ternary.c b/test/monniaux/ternary/ternary.c
index 45201ff8..79025639 100644
--- a/test/monniaux/ternary/ternary.c
+++ b/test/monniaux/ternary/ternary.c
@@ -5,10 +5,16 @@
typedef uint32_t data;
+#if 0
+#define TERNARY(a, b, c) ((a) ? (b) : (c))
+#else
+#define TERNARY(a, b, c) (((-(a)) & (b)) | ((-1+(a)) & (c)))
+#endif
+
data silly_computation(void) {
data x = 1;
for(int i=0; i<10000; i++) {
- x = x * (((x & 0x100) != 0) ? 45561U : 337777U);
+ x = x * TERNARY(((x & 0x100) != 0), 45561U, 337777U);
}
return x;
}