-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Time.at loses precision when using BigDecimal as argument #3616
Comments
This is a known issue...as in I've known about it. MRI represents their Time object internally with much more type flexibility...Bignums, Bigdecimals, Rationals. We do not have this flexibility wired into our various Time constructors and methods. In this case, I'd guess we're simply truncating to Fixnum any input to Time.at. @alex88 I wonder if you'd like to expand the test cases for Time.at (and friends) in https://github.com/ruby/spec? It appears we're failing two cases related to |
@headius correct me if I'm wrong, but you're not truncating to Fixnum, as Anyway, I'm gonna work on ruby/spec to add the tests with BigNumber later this week |
I have a fix for this based on a quick look at MRI's code. The two main issues were that we forced non-Float/Rational to Fixnum (rather than coercing to Rational), and our BigDecimal.to_r was broken. |
@alex88 The incoming value for |
Wow that was fast, thanks @headius! |
@alex88 You're welcome! Could you add a couple quick specs to https://github.com/ruby/spec so we've got coverage? |
@headius doing that now, however jruby 9.0.4.0 have like 143 failures already, is that expected? PS: I'm running ruby specs inside an |
For example the time specs:
|
Just tried setting also jruby as global default implementation, same thing |
I was debugging why logstash was losing precision with a gelf input, it ended up to be a jRuby bug (maybe).
These are the steps to reproduce the issue:
The text was updated successfully, but these errors were encountered: