# BigDecimal and BigMath

**URL:** <https://www.ruby-forum.com/t/bigdecimal-and-bigmath/180292>\
**Category:** Ruby\
**Created:** [December 16, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/bigdecimal-and-bigmath/180292 "2009-12-16T18:33:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![devbanana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e8cbc/32.png) [@devbanana](https://www.ruby-forum.com/u/devbanana)\
**Post date:** [December 16, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/bigdecimal-and-bigmath/180292/1 "2009-12-16T18:33:25Z")

</div>

Hi,

I am developing an application that requires very large numbers, so I am  
using BigDecimal.

I wanted to use atan, and saw that there was a bigdecimal/math, which  
allows  
you to use an atan that supports BigDecimal. However it seems faulty. It  
says you cannot pass a value for x that is greater than 1 or less than  
-1.  
As far as I know, there is no such limit for the arctan. Also there is  
no  
asin or acos.

Are there any alternatives that support a bit more in terms of trig  
functions?

Also, I wanted to ask whether there was any practical limit to the  
precision  
of a BigDecimal number? I’m looking at numbers in orders of magnitude  
between about 15-25 at most.

Thanks,  
Brandon

---

<div class="post-metadata">

**Author:** ![devbanana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e8cbc/32.png) [@devbanana](https://www.ruby-forum.com/u/devbanana)\
**Post date:** [December 16, 2009, 7:51pm UTC](https://www.ruby-forum.com/t/bigdecimal-and-bigmath/180292/2 "2009-12-16T19:51:42Z")

</div>

Brandon O. wrote:

> I am developing an application that requires very large numbers, so I am  
> using BigDecimal.

Floats can handle pretty large numbers, too:

irb(main):009:0\> 2.0 \*\* 1000  
=\> 1.07150860718627e+301

It’s more a question of how much precision you need.

---

<div class="post-metadata">

**Author:** ![devbanana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e8cbc/32.png) [@devbanana](https://www.ruby-forum.com/u/devbanana)\
**Post date:** [December 16, 2009, 9:17pm UTC](https://www.ruby-forum.com/t/bigdecimal-and-bigmath/180292/3 "2009-12-16T21:17:18Z")

</div>

On 2009-12-16, Brian C. wrote:

> Brandon O. wrote:
> 
> > I am developing an application that requires very large numbers, so  
> > I am using BigDecimal.
> 
> Floats can handle pretty large numbers, too:
> 
> irb(main):009:0\> 2.0 \*\* 1000  
> =\> 1.07150860718627e+301
> 
> It’s more a question of how much precision you need.

Agreed, but these numbers will be used in calculations, so I feel a bit  
more comfortable with BigDecimal.

The precision I need varies. It’ll use a lot of trig, and those should  
be as exact as possible.

Brandon

---

<div class="post-metadata">

**Author:** ![devbanana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e8cbc/32.png) [@devbanana](https://www.ruby-forum.com/u/devbanana)\
**Post date:** [December 17, 2009, 2:58pm UTC](https://www.ruby-forum.com/t/bigdecimal-and-bigmath/180292/4 "2009-12-17T14:58:57Z")

</div>

Brandon O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> says you cannot pass a value for x that is greater than 1 or less than -1.  
> As far as I know, there is no such limit for the arctan. Also there is no

Hi Brandon,

[-1,1] is basically all you need, since

arctan(x) = sgn(x) \* Pi/2 - arctan(1/x)

Flo

---

<div class="post-metadata">

**Author:** ![devbanana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e8cbc/32.png) [@devbanana](https://www.ruby-forum.com/u/devbanana)\
**Post date:** [December 17, 2009, 3:18pm UTC](https://www.ruby-forum.com/t/bigdecimal-and-bigmath/180292/5 "2009-12-17T15:18:16Z")

</div>

Florian W. wrote:

> arctan(x) = sgn(x) \* Pi/2 - arctan(1/x)
> 
> Flo

sure, but this is just a feature special to arctan. It might be used for  
implementation, but should not limit the set input values (i.e. its  
interface)

regards  
ralf
