BigDecimal and BigMath

B

Brandon Olivares

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
 
B

Brian Candler

Brandon said:
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.
 
B

Brandon Olivares

=20
Floats can handle pretty large numbers, too:
=20
irb(main):009:0> 2.0 ** 1000
=3D> 1.07150860718627e+301
=20
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
 
F

Florian Weingarten

Brandon Olivares said:
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
 
R

Ralf Mueller

Florian said:
Brandon Olivares said:
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
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top