-
Notifications
You must be signed in to change notification settings - Fork 131
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigInt problem with hexdigit string #70
Comments
int get_val(char c) {
assert(('0' <= c and c <= '9') or ('a' <= c and c <= 'f'));
if ('0' <= c and c <= '9')
return c - '0';
else
return c - 'a' + 10;
}
BigInt hex_to_BigInt(const std::string& hex) {
assert(!hex.empty());
BigInt res = 0, p = 1;
for (auto it = hex.rbegin(); it != hex.rend(); it++) {
res += p * get_val(*it);
p *= 16;
}
return res;
} I had something similar to this in mind. Do we have any library specific optimizations? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BigInt header only does not work with hexdigit string like
std::string hexStr = "123456789abcdef123456789abcdef";
It is very kind of you to extend it.
Best thanks
The text was updated successfully, but these errors were encountered: