diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-10 13:53:57 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-10 13:53:57 +0200 |
commit | ad5394d591896fc1d025efff2fa6c8c580fb67e9 (patch) | |
tree | 5885517e9057337fa886b0ccb863ccbe19dd188c /coreutils | |
parent | dd3a3950531396296f062d4764f26c32a803458a (diff) | |
download | busybox-w32-ad5394d591896fc1d025efff2fa6c8c580fb67e9.tar.gz busybox-w32-ad5394d591896fc1d025efff2fa6c8c580fb67e9.tar.bz2 busybox-w32-ad5394d591896fc1d025efff2fa6c8c580fb67e9.zip |
factor: add code to test isqrt() correctness
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/factor.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/coreutils/factor.c b/coreutils/factor.c index 4a131813b..7400174a7 100644 --- a/coreutils/factor.c +++ b/coreutils/factor.c | |||
@@ -203,6 +203,23 @@ static NOINLINE void factorize(wide_t N) | |||
203 | int factor_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 203 | int factor_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
204 | int factor_main(int argc UNUSED_PARAM, char **argv) | 204 | int factor_main(int argc UNUSED_PARAM, char **argv) |
205 | { | 205 | { |
206 | #if 0 /* test isqrt() correctness */ | ||
207 | wide_t n = argv[1] ? bb_strtoull(argv[1], NULL, 0) : time(NULL); | ||
208 | for (;;) { | ||
209 | half_t h; | ||
210 | if (--n == 0) | ||
211 | --n; | ||
212 | h = isqrt(n); | ||
213 | if (!(n & 0xff)) | ||
214 | printf("isqrt(%llx)=%"HALF_FMT"x\n", n, h); | ||
215 | if ((wide_t)h * h > n) | ||
216 | return 1; | ||
217 | h++; | ||
218 | if (h != 0 && (wide_t)h * h <= n) | ||
219 | return 1; | ||
220 | } | ||
221 | #endif | ||
222 | |||
206 | //// coreutils has undocumented option ---debug (three dashes) | 223 | //// coreutils has undocumented option ---debug (three dashes) |
207 | //getopt32(argv, ""); | 224 | //getopt32(argv, ""); |
208 | //argv += optind; | 225 | //argv += optind; |