bigdecimal
bigdecimal copied to clipboard
Arbitrary-precision decimal floating-point number library for Ruby
`BigDecimal::INFINITY.round` shouldn't cause `FloatDomainError` when `BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY) == 0` but it raises the error. ``` $ ruby -rbigdecimal -e "BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, false); BigDecimal::INFINITY.round" -e:1:in `round': Computation results in 'Infinity' (FloatDomainError) from -e:1:in...
1. The documentation of `Float#to_d` still mentions the old default value of `precision` (`Float::DIG`). I've updated it and described what does the `precision=0` mean. 2. The description of `ndigits=0` disappeared...
Fixes https://github.com/ruby/bigdecimal/issues/78 by describing behaviour for positive and negative zero in the docs.
## Associated issue: #81 ## Context `BigMath` module supports sine (`sin`) and cosine (`cos`) trigonometric functions. It also supports arctangent (`acan`). But it doesn't support tangent, which is supported in...
We've observed that BigDecimal treats number and string differently on max precision allocation. Ruby 2.6.6 ```ruby # precs returns [SIZET2NUM(p->Prec*VpBaseFig()), SIZET2NUM(p->MaxPrec*VpBaseFig())] BigDecimal(123).precs => [9, 27] BigDecimal('123').precs => [9, 18] BigDecimal(123456789).precs...
[Bug [#18677](https://bugs.ruby-lang.org/issues/18677)]
I upgraded to BigDecimal 3.1.2 to pull in the fix to #220, which was causing crashes in our Rails app. However, I believe the fix applied in 127a1b5 created the...
```ruby require 'bigdecimal' bd = BigDecimal("4.2") bd.remainder(BigDecimal("+Infinity")) # => NaN, should be bd bd.remainder(BigDecimal("-Infinity")) # => NaN, should be bd ``` See https://bugs.ruby-lang.org/issues/6120 I've submitted a pull request to ruby...
``` irb(main):002:0> BigDecimal(5.1) (irb):2:in `BigDecimal': can't omit precision for a Float. (ArgumentError) from (irb):2:in `' from /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.8.pre.9/exe/irb:11:in `' from /home/mrkn/.rbenv/versions/3.0/bin/irb:23:in `load' from /home/mrkn/.rbenv/versions/3.0/bin/irb:23:in `' ``` This should works like below....
Doc for method BigDecimal says: * ArgumentError:: If +initial+ is a Float, and the +digits+ is larger than * Float::DIG + 1, this exception is raised. Is this true for...