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

Different behavior than expected with commas #308

Open
jose-sherpa opened this issue Dec 13, 2024 · 1 comment
Open

Different behavior than expected with commas #308

jose-sherpa opened this issue Dec 13, 2024 · 1 comment

Comments

@jose-sherpa
Copy link

I feel like the following shouldn't happen

(ebr) DEVELOPMENT :001:0> BigDecimal("1,567.67")
(ebr):1:in `BigDecimal': invalid value for BigDecimal(): "1,567.67" (ArgumentError)

BigDecimal("1,567.67")
           ^^^^^^^^^^
	from (ebr):1:in `<main>'
(ebr) DEVELOPMENT :002:0> BigDecimal("1567.67")
=> 0.156767e4
(ebr) DEVELOPMENT :003:0> "1567.67".to_d
=> 0.156767e4
(ebr) DEVELOPMENT :004:0> "1,567.67".to_d
=> 0.1e1
(ebr) DEVELOPMENT :005:0> "1567.67".to_f
=> 1567.67
(ebr) DEVELOPMENT :006:0> "1567.67".to_f.to_d
=> 0.156767e4
@midnight-wonderer
Copy link

I don't quite see what you're trying to convey. Maybe a bit of explanation would help?
BigDecimal() is the strict version of to_d, which consistent with the relationship of Integer() and to_i.

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

No branches or pull requests

2 participants