aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/12-flt.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-07 12:34:27 +0100
committerlemon <lsof@mailbox.org>2025-12-07 12:34:27 +0100
commitbfc6b66078ab3ec543b8355ad22df1c423bf9a8c (patch)
tree374a52bdad94ad2b104afb556dbbede6626fa75e /test/12-flt.c
parentf6a21adc858dda2f9b38eac38bce9b3202c04ec5 (diff)
test/12-flt: add some weird float cmp edgecases
Diffstat (limited to 'test/12-flt.c')
-rw-r--r--test/12-flt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/test/12-flt.c b/test/12-flt.c
index 295e40f..36f4e90 100644
--- a/test/12-flt.c
+++ b/test/12-flt.c
@@ -1,5 +1,6 @@
+/* CFLAGS: -lm */
/* EXPECT:
-ok
+ok -0.0
*/
typedef unsigned u32;
typedef signed s32;
@@ -32,6 +33,12 @@ f64 f32_to_f64(f32 x) { return x; }
double NAN = 0.0;
double _(double x) { return x; }
+double fmod(double, double);
+double nummod(double a, double b) {
+ double m = fmod(a,b);
+ if ((m > 0) ? (printf("bluh\n"), b < 0) : (m < 0 && b > 0)) m += b;
+ return m;
+}
int main() {
NAN/=0.0;
@@ -49,5 +56,5 @@ int main() {
assert(!(NAN == NAN));
assert(NAN != NAN);
assert(NAN != 0.0);
- printf("ok\n");
+ printf("ok %.1f\n", nummod(-10.0, -2.0));
}