Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug #15454 results from a bug in GMP. If you pass in a string '0xABCD' and specify a base of 0, GMP figures out that it is hex and skips over the 0x characters. If you specify base 16, then it doesn't skip those chars. This was confirmed with the following test program: #include <stdio.h> #include <gmp.h> int main() { char *str_one, *str_two; mpz_t num_one, num_two; mpz_init_set_str (num_one, "0x45", 0); str_one = mpz_get_str(NULL, 10, num_one); mpz_init_set_str (num_two, "0x45", 16); str_two = mpz_get_str(NULL, 10, num_two); printf("%s / %s\n", str_one, str_two); mpz_clear (num_one); mpz_clear (num_two); return 0; } We now take anything that starts with 0[xX] as hexidecimal and anything that starts 0[bB] as binary (this is what GMP does internally). We also no longer force the base to 10 or 16, but instead let GMP decide what the best base is, be it hex, dec, or octal.
- Loading branch information