diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-04-27 17:46:48 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-04-27 17:46:48 +0000 |
commit | 4d4116761958b945bbc20fb5a5495c1cc7a897c0 (patch) | |
tree | 177e88316908c6c765dd3bde9ab4ac7cfb5a73b7 /lib/libc/quad/TESTS | |
parent | 3fd98b3b1027bc45b04855550bc44e05c0a9e95d (diff) |
A quad is two ints, not two longs. Also fix some problems with
conversions from floating point to quad. Problem reported by Marcus
Holland-Moritz. From NetBSD.
ok millert@
Diffstat (limited to 'lib/libc/quad/TESTS')
-rw-r--r-- | lib/libc/quad/TESTS/divrem.c | 14 | ||||
-rw-r--r-- | lib/libc/quad/TESTS/mul.c | 12 |
2 files changed, 13 insertions, 13 deletions
diff --git a/lib/libc/quad/TESTS/divrem.c b/lib/libc/quad/TESTS/divrem.c index 4254f7c4a10..394793545f9 100644 --- a/lib/libc/quad/TESTS/divrem.c +++ b/lib/libc/quad/TESTS/divrem.c @@ -38,14 +38,14 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char rcsid[] = "$OpenBSD: divrem.c,v 1.3 2003/06/02 20:18:36 millert Exp $"; +static char rcsid[] = "$OpenBSD: divrem.c,v 1.4 2004/04/27 17:46:46 otto Exp $"; #endif /* not lint */ #include <stdio.h> main() { - union { long long q; unsigned long v[2]; } a, b, q, r; + union { long long q; unsigned int v[2]; } a, b, q, r; char buf[300]; extern long long __qdivrem(unsigned long long, unsigned long long, unsigned long long *); @@ -54,19 +54,19 @@ main() printf("> "); if (fgets(buf, sizeof buf, stdin) == NULL) break; - if (sscanf(buf, "%lu:%lu %lu:%lu", + if (sscanf(buf, "%u:%u %u:%u", &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 && - sscanf(buf, "0x%lx:%lx 0x%lx:%lx", + sscanf(buf, "0x%x:%x 0x%x:%x", &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) { printf("eh?\n"); continue; } q.q = __qdivrem(a.q, b.q, &r.q); - printf("%lx:%lx /%% %lx:%lx => q=%lx:%lx r=%lx:%lx\n", + printf("%x:%x /%% %x:%x => q=%x:%x r=%x:%x\n", a.v[0], a.v[1], b.v[0], b.v[1], q.v[0], q.v[1], r.v[0], r.v[1]); - printf(" = %lX%08lX / %lX%08lX => %lX%08lX\n\ - = %lX%08lX %% %lX%08lX => %lX%08lX\n", + printf(" = %X%08X / %X%08X => %X%08X\n\ + = %X%08X %% %X%08X => %X%08X\n", a.v[0], a.v[1], b.v[0], b.v[1], q.v[0], q.v[1], a.v[0], a.v[1], b.v[0], b.v[1], r.v[0], r.v[1]); } diff --git a/lib/libc/quad/TESTS/mul.c b/lib/libc/quad/TESTS/mul.c index 63282435219..bd5e562b42e 100644 --- a/lib/libc/quad/TESTS/mul.c +++ b/lib/libc/quad/TESTS/mul.c @@ -38,14 +38,14 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char rcsid[] = "$OpenBSD: mul.c,v 1.3 2003/06/02 20:18:36 millert Exp $"; +static char rcsid[] = "$OpenBSD: mul.c,v 1.4 2004/04/27 17:46:47 otto Exp $"; #endif /* not lint */ #include <stdio.h> main() { - union { long long q; unsigned long v[2]; } a, b, m; + union { long long q; unsigned int v[2]; } a, b, m; char buf[300]; extern long long __muldi3(long long, long long); @@ -53,17 +53,17 @@ main() printf("> "); if (fgets(buf, sizeof buf, stdin) == NULL) break; - if (sscanf(buf, "%lu:%lu %lu:%lu", + if (sscanf(buf, "%u:%u %u:%u", &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 && - sscanf(buf, "0x%lx:%lx 0x%lx:%lx", + sscanf(buf, "0x%x:%x 0x%x:%x", &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) { printf("eh?\n"); continue; } m.q = __muldi3(a.q, b.q); - printf("%lx:%lx * %lx:%lx => %lx:%lx\n", + printf("%x:%x * %x:%x => %x:%x\n", a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]); - printf(" = %lX%08lX * %lX%08lX => %lX%08lX\n", + printf(" = %X%08X * %X%08X => %X%08X\n", a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]); } exit(0); |