Skip to content

Commit

Permalink
Fix 128-bit integer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Mar 27, 2023
1 parent 930073a commit b562048
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions test/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ int main()
std::cout << "pi(" << in << ") = " << out;
check(out == "0");

// Test using INT128_MIN
in = "-170141183460469231731687303715884105728";
// Test using INT128_MIN+1
in = "-170141183460469231731687303715884105727";
out = pi(in);
std::cout << "pi(" << in << ") = " << out;
check(out == "0");
Expand Down
6 changes: 3 additions & 3 deletions test/api_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ int main(void)
printf("primecount_pi_str(-1208925819614629174696176) = %s", out);
check(strcmp(out, "0") == 0);

// Test using INT128_MIN
primecount_pi_str("-170141183460469231731687303715884105728", out, sizeof(out));
printf("primecount_pi_str(-170141183460469231731687303715884105728) = %s", out);
// Test using INT128_MIN+1
primecount_pi_str("-170141183460469231731687303715884105727", out, sizeof(out));
printf("primecount_pi_str(-170141183460469231731687303715884105727) = %s", out);
check(strcmp(out, "0") == 0);
}

Expand Down

0 comments on commit b562048

Please sign in to comment.