Skip to content

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

Open
BenBE wants to merge 1 commit intobeargiles:masterfrom
BenBE:hex-support
Open

add: Support hex notation by 0xabcd when converting to bignum values#1
BenBE wants to merge 1 commit intobeargiles:masterfrom
BenBE:hex-support

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