Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.3.1, JRuby 1.5.3
-
Fix Version/s: JRuby 1.2, JRuby 1.6RC3
-
Component/s: Core Classes/Modules, Intro
-
Labels:None
-
Environment:Mac OS X 10.6
-
Number of attachments :
Description
jruby -ve 'require "bigdecimal"; n = BigDecimal("1").div(BigDecimal("3"), 307); p n, n.to_f; n = BigDecimal("1").div(BigDecimal("3") , 308); p n, n.to_f'
{{jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-03-16 rev 9419) [x86_64-java]
#<BigDecimal:19fac852,'0.3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333E0',307(308)>
0.333333333333333
#<BigDecimal:46da3772,'0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333E0',308(312)>
0.333333333333333
}}
{{jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_22) [x86_64-java]
#<BigDecimal:418a9fc8,'0.3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333E0',307(308)>
0.333333333333333
#<BigDecimal:558041e0,'0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333E0',308(312)>
0.0
}}
Issue Links
- is duplicated by
-
JRUBY-5191
BigDecimal#to_f always returns 0.0 for large precisions
-
Send a patch with test your example as test case.
https://github.com/jruby/jruby/pull/25