My experiments show differences to host 'dc'.
Starting with this INT64_MAX=9223372036854775807 dividend.
bb 'dc' can't cope with such big integers:
1. FAILED: '9223372036854775807 % 2' -> bb: 0, host: 1
2. FAILED: '4611686018427387903 % 2' -> bb: 0, host: 1
3. FAILED: '2305843009213693951 % 2' -> bb: 0, host: 1
4. FAILED: '1152921504606846975 % 2' -> bb: 0, host: 1
5. FAILED: '576460752303423487 % 2' -> bb: 0, host: 1
6. FAILED: '288230376151711743 % 2' -> bb: 0, host: 1
7. FAILED: '144115188075855871 % 2' -> bb: 0, host: 1
8. FAILED: '72057594037927935 % 2' -> bb: 0, host: 1
9. FAILED: '36028797018963967 % 2' -> bb: 0, host: 1
10. FAILED: '18014398509481983 % 2' -> bb: 0, host: 1
but starts working here:
11. SUCCEDED: '9007199254740991 % 2' -> bb: 1, host: 1
12. SUCCEDED: '4503599627370495 % 2' -> bb: 1, host: 1
and all the way down. Still, the unsigned int cast should prevent it
from working until the UINT32_MAX=4294967295 dividend is reached. True?
Checking the divisor now. Starting with 2:
1. SUCCEDED: '18014398509481982 % 2' -> bb: 0, host: 0
2. SUCCEDED: '18014398509481982 % 4' -> bb: 2, host: 2
bb 'dc' copes with divisors up to 524288:
18. SUCCEDED: '18014398509481982 % 262144' -> bb: 262142, host: 262142
19. SUCCEDED: '18014398509481982 % 524288' -> bb: 524286, host: 524286
works even further, but starts showing float formated numbers:
20. FAILED: '18014398509481982 % 1048576' -> bb: 1.04857e+06, host: 1048574
21. FAILED: '18014398509481982 % 2097152' -> bb: 2.09715e+06, host: 2097150
up to a point INT32_MAX=2147483647:
31. FAILED: '18014398509481982 % 2147483648' -> bb: 2.14748e+09, host:
2147483646
and then, at UINT32_MAX=4294967295 divisor, stops working:
32. FAILED: '18014398509481982 % 4294967296' -> bb: ???, host: 4294967294
But host 'dc' keeps working:
51. FAILED: '18014398509481982 % 2251799813685248' -> bb: ???, host:
2251799813685246
52. FAILED: '18014398509481982 % 4503599627370496' -> bb: ???, host:
4503599627370494
53. FAILED: '18014398509481982 % 9007199254740992' -> bb: ???, host:
9007199254740990
Things improve with this attempt:
--- busybox/miscutils/dc.c.orig 2010-07-27 16:22:22.000000000 +0200
+++ busybox/miscutils/dc.c.cii2 2010-07-27 16:44:37.000000000 +0200
@@ -73,9 +73,9 @@
static void mod(void)
{
- unsigned d = pop();
+ uint64_t d = (uint64_t) pop();
- push((unsigned) pop() % d);
+ push((uint64_t) pop() % d);
}
static void and(void)
in the divisor area. Results still show up as float formated numbers,
but it works with big divisors:
52. FAILED: '18014398509481982 % 4503599627370496' -> bb: 4.5036e+15, host:
4503599627370494
53. FAILED: '18014398509481982 % 9007199254740992' -> bb: 9.0072e+15, host:
9007199254740990
Cheers,
--
Cristian
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox