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

Allow underscores when initlalising BigInt #7106

Closed
alex-kampa opened this issue Nov 23, 2018 · 2 comments
Closed

Allow underscores when initlalising BigInt #7106

alex-kampa opened this issue Nov 23, 2018 · 2 comments

Comments

@alex-kampa
Copy link

In order to be consistent with how integers are handled, it will be good to allow BigInt initialisations with underscore like this:

BigInt.new("FFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFE_FFFFEE37", base: 16),

@JacobUb
Copy link
Contributor

JacobUb commented Nov 23, 2018

Perhaps it would be more consistent to change String#to_big_i so that it has the same interface as String#to_i, including the arguments underscore, strict, etc.

@bcardiff
Copy link
Member

Having at least the _ handled would be good for consistency with respect how numbers literals are supported.

Ignoring whitespaces is already allowed by default in LibGMP and can't be turned off, so having exactly the same behavior would require manual validation. That could makes sense in String#to_big_i, but I would say to make BigInt.new consistent with the built in numbers parsing rules (ie: handle _)

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

No branches or pull requests

3 participants