Hi, working on a project which must calculate natural logarithms, I see calculators do it all over, but my luck with source code evaluation hasn't turned up what I need.

you're seeing your results rounded to the nearest integer value because you're storing them in a BigInteger variable. have you tried using BigDecimal instead?

Tom Clement
Greenhorn

Joined: Mar 21, 2004
Posts: 26

posted

0

No, I haven't yet, I'll try it now, thanks

Tom Clement
Greenhorn

Joined: Mar 21, 2004
Posts: 26

posted

0

tried BigDecimal, it's not a straightforward swap, it'll take more time than I have tonight, I'll definitely try tomorrow. With all those calculators out there, I'm hoping someone's done this already.

Why can't you use java.lang.Math.log(double)? Since you're taking the double value of your BigInteger (and eventually BigDecimal), why bother with those classes at all?

As their names imply, BigInteger and BigDecimal are meant to be used for arbitrarily large numbers. Unless, you are using numbers that are over 9*10^19 (the maximum value for a long), then you should probably just use the built-in types like double and long. The Math class from the standard API provides methods to perform just about any mathematical operation you need. These include the basic trigonometric functions and logarithms, to name a few.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com