← Commit list

ad5394d59

Denys Vlasenko
Denys Vlasenko
2017-04-10
SUCCESS Duration: 141s

Subject

factor: add code to test isqrt() correctness

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/factor.c+17 -0
@@ -203,6 +203,23 @@ static NOINLINE void factorize(wide_t N)
int factor_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int factor_main(int argc UNUSED_PARAM, char **argv)
{
+#if 0 /* test isqrt() correctness */
+ wide_t n = argv[1] ? bb_strtoull(argv[1], NULL, 0) : time(NULL);
+ for (;;) {
+ half_t h;
+ if (--n == 0)
+ --n;
+ h = isqrt(n);
+ if (!(n & 0xff))
+ printf("isqrt(%llx)=%"HALF_FMT"x\n", n, h);
+ if ((wide_t)h * h > n)
+ return 1;
+ h++;
+ if (h != 0 && (wide_t)h * h <= n)
+ return 1;
+ }
+#endif
+
//// coreutils has undocumented option ---debug (three dashes)
//getopt32(argv, "");
//argv += optind;