On Wed, Mar 16, 2011 at 4:03 PM, Reinier Zwitserloot <[email protected]>wrote:

> Many mathematical operations simply do not work on arbitrary precision
> numbers. For example, SQRT(2), in a world of infinite precision, would never
> finish. Thus, the API is going to end up as a clunky mess where every
> operation requires a context to explain exactly how precise the answer would
> have to be. BigDecimal is that kind of library and is hence rather clunky.
> It's also prone to throw exceptions (that's what it'll do if you for example
> try to divide 2.0 by 3.0, as the result cannot be stored as BD without
> putting a limit on precision somewhere).
>
>
Your example of square roots resulting in irrational numbers is easily
solved by simply using mandating that results have a precision limit as an
be found on MathContext.


> Nevertheless, yes, BD doesn't nearly have everything one could be looking
> for. Fortunately I've never run into the need to have more than BD has.
>
> Isn't integration of BigDecimal and BigInteger a bit of a red herring? You
> can just use BigDecimal everywhere, the impact of using it instead of a
> BigInteger on memory/CPU is probably negligible (as in, usage of BD/BI over
> primitive math is already gigantic, I doubt the small difference between
> BD/BI is going to be noticeable).
>
>
>
Probably but given that there are many APIs that take a BD, if your library
has its own custom decimal class it would be nice if one could pass a BD to
the custom decimal and rip one out when needed. The same goes for BI. I too
have never needed BI for any of its bit fiddling methods but still for
completeness its nice to have.


> What kind of operations are you doing if you want both performance and more
> precision than double can give you? That's an awfully fine line to walk.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>



-- 
mP

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to