From fe57280950fc20b2d1650a022033484b152ae51d Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sat, 14 Feb 2015 11:08:57 +0100 Subject: C reference implementation of the int64 helper functions. In test_int64.c: don't test FP->int64 conversions when the FP argument is out of range. --- runtime/test/test_int64.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'runtime/test') diff --git a/runtime/test/test_int64.c b/runtime/test/test_int64.c index ab7a231d..58a129b6 100644 --- a/runtime/test/test_int64.c +++ b/runtime/test/test_int64.c @@ -158,17 +158,21 @@ static void test1(u64 x, u64 y) u = __i64_stof(x); v = (float) (s64) x; if (u != v) - error++, printf("(double) %lld (s) = %a, expected %a\n", x, u, v); + error++, printf("(float) %lld (s) = %a, expected %a\n", x, u, v); f = (double) x; - z = __i64_dtou(f); - if (z != (u64) f) - error++, printf("(u64) %a = %llu, expected %llu\n", f, z, (u64) f); + if (f >= 0 && f < 0x1p+64) { + z = __i64_dtou(f); + if (z != (u64) f) + error++, printf("(u64) %a = %llu, expected %llu\n", f, z, (u64) f); + } f = (double) (s64) x; - t = __i64_dtos(f); - if (t != (s64) f) - error++, printf("(s64) %a = %lld, expected %lld\n", f, z, (s64) f); + if (f >= -0x1p+63 && f < 0x1p+63) { + t = __i64_dtos(f); + if (t != (s64) f) + error++, printf("(s64) %a = %lld, expected %lld\n", f, z, (s64) f); + } f = ((double) x) * 0.0001; z = __i64_dtou(f); -- cgit