diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-06-15 19:36:33 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-06-15 19:36:33 +0000 |
commit | ea76864009c3d7458b466123ae7cf10daafde53b (patch) | |
tree | 3aeadd87a0b3122ecd4ef1d779da21357edb7a7b /tests/test-i386.c | |
parent | 43ce4dfe9efd48694cc7e9312f4e845304b2e532 (diff) | |
download | qemu-ea76864009c3d7458b466123ae7cf10daafde53b.zip qemu-ea76864009c3d7458b466123ae7cf10daafde53b.tar.gz qemu-ea76864009c3d7458b466123ae7cf10daafde53b.tar.bz2 |
more precise float rounding tests
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@230 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'tests/test-i386.c')
-rw-r--r-- | tests/test-i386.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/test-i386.c b/tests/test-i386.c index 56dc6af..c2c3323 100644 --- a/tests/test-i386.c +++ b/tests/test-i386.c @@ -527,6 +527,12 @@ void test_fcvt(double a) { float fa; long double la; + int16_t fpuc; + int i; + int64_t lla; + int ia; + int16_t wa; + double ra; fa = a; la = a; @@ -535,9 +541,21 @@ void test_fcvt(double a) printf("a=%016Lx\n", *(long long *)&a); printf("la=%016Lx %04x\n", *(long long *)&la, *(unsigned short *)((char *)(&la) + 8)); - printf("a=%f floor(a)=%f\n", a, floor(a)); - printf("a=%f ceil(a)=%f\n", a, ceil(a)); - printf("a=%f rint(a)=%f\n", a, rint(a)); + + /* test all roundings */ + asm volatile ("fstcw %0" : "=m" (fpuc)); + for(i=0;i<4;i++) { + asm volatile ("fldcw %0" : : "m" ((fpuc & ~0x0c00) | (i << 10))); + asm volatile ("fist %0" : "=m" (wa) : "t" (a)); + asm volatile ("fistl %0" : "=m" (ia) : "t" (a)); + asm volatile ("fistpll %0" : "=m" (lla) : "t" (a) : "st"); + asm volatile ("frndint ; fstl %0" : "=m" (ra) : "t" (a)); + asm volatile ("fldcw %0" : : "m" (fpuc)); + printf("(short)a = %d\n", wa); + printf("(int)a = %d\n", ia); + printf("(int64_t)a = %Ld\n", lla); + printf("rint(a) = %f\n", ra); + } } #define TEST(N) \ @@ -625,9 +643,12 @@ void test_floats(void) test_fcmp(2, -1); test_fcmp(2, 2); test_fcmp(2, 3); + test_fcvt(0.5); + test_fcvt(-0.5); test_fcvt(1.0/7.0); test_fcvt(-1.0/9.0); - test_fcvt(1e30); + test_fcvt(32768); + test_fcvt(-1e20); test_fconst(); test_fbcd(1234567890123456); test_fbcd(-123451234567890); |