Skip to content
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

add: Support hex notation by 0xabcd when converting to bignum values #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BenBE
Copy link

@BenBE BenBE commented Sep 17, 2015

As some if not most big numbers are usually given in hex it's nice to have a direct way of importing/converting them from string. Given that parsing hex to binary is even much faster than base conversion from base 10 to base 256 (for binary) it's highly recommended to prefer hex input for performance.

For output both formats have their advantages ...

@EvanCarroll
Copy link

EvanCarroll commented Dec 9, 2017

Ohh, I see what asc2bn does,.

BN_asc2bn() infers the number base from an optional prefix. If str starts with “0x” or “0X”, it calls BN_hex2bn(), otherwise BN_dec2bn().

That's brilliant for coercion. Though I think we should keep the same behavior for in/out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants