From 9b3388bea495d027aa618118096a8223f6866437 Mon Sep 17 00:00:00 2001 From: xleroy Date: Mon, 6 May 2013 08:20:06 +0000 Subject: Support for in64 -> float conversions w/ correct rounding. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2235 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- runtime/test/test_int64.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'runtime/test/test_int64.c') diff --git a/runtime/test/test_int64.c b/runtime/test/test_int64.c index 4dbad707..2aa21117 100644 --- a/runtime/test/test_int64.c +++ b/runtime/test/test_int64.c @@ -52,6 +52,8 @@ extern s64 __i64_sar(s64 x, unsigned amount); extern double __i64_utod(u64 x); extern double __i64_stod(s64 x); +extern float __i64_utof(u64 x); +extern float __i64_stof(s64 x); extern u64 __i64_dtou(double d); extern s64 __i64_dtos(double d); @@ -70,6 +72,7 @@ static void test1(u64 x, u64 y) s64 t, sy; int i; double f, g; + float u, v; if (y != 0) { @@ -147,14 +150,24 @@ static void test1(u64 x, u64 y) if (f != g) error++, printf("(double) %lld (s) = %a, expected %a\n", x, f, g); + u = __i64_utof(x); + v = (float) x; + if (u != v) + error++, printf("(float) %llu (u) = %a, expected %a\n", x, u, v); + + u = __i64_stof(x); + v = (float) (s64) x; + if (u != v) + error++, printf("(double) %lld (s) = %a, expected %a\n", x, u, v); + f = (double) x; z = __i64_dtou(f); - if (z != (u64) (double) f) + if (z != (u64) f) error++, printf("(u64) %a = %llu, expected %llu\n", f, z, (u64) f); - f = (double) ((s64) x); + f = (double) (s64) x; t = __i64_dtos(f); - if (t != (s64) (double) f) + if (t != (s64) f) error++, printf("(s64) %a = %lld, expected %lld\n", f, z, (s64) f); f = ((double) x) * 0.0001; -- cgit