I'm writing a java applet where I need to be able to get perfectly consistent results for any given set of calculations, no matter what version of the JRE is on the client computer. This is mildly problematic thanks to the fact that Sun has renamed the Math class to the StrictMath class, and created a new version of the Math class for later versions of the JRE.

My applet provides consistent results for anyone using a version of java above 1.3.0 (the newer version of the Math class), and consistent results for anyone using a version of java below 1.3.0 (the old version of the Math Class that got renamed to StrictMath); but these two sets of results, while consistent, are different from each other.

Does anyone have any suggestions as to how to solve this? Precision isn't vital to the results, but consistency is.

The pre-1.3.0 Math class was renamed to StrictMath thereafter. Sorry, I probably wasn't clear . . .

I'm using the Math class all the way through here as a blanket thing, not the StrictMath class. I can determine the version of the JRE present . . . However, if I try and use the StrictMath class in the project I can't run it under older versions of the JRE, as the class isn't present when the applet tries to load it.

0

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Does the pre-1.3 Math class provide consistent results with the StrictMath class?

If so, you could create a wrapper class that channelled the call to the correct class depending on the vm version.

0

RezantisAuthor Commented:

You're right, that does imply that. ^^;

I can't use StrictMath for consistency, though, because I need this to work on older versions of the JRE . . . and as far as I've been able to tell, pre 1.3 Math class does provide consistent results. If it does differ, it's minor enough that it's not shown up as a problem to me befoer. ^^

How would I go about creating a wrapper class to do that without throwing the class loading exceptions? It's probably not that complicated in it's calls, I'm just not sure how to load one class and not another.

> renamed the Math class to the StrictMath class

Are you sure about that, as it is not my understanding.

Do you have a reference confirming that?

> but these two sets of results, while consistent, are different from each other.

This sort of implies that Sun didn't rename Math to StrictMath doesn't it?

afaik you can only get consistency using StrictMath. ie. you cannot support earlier vm versions <1.3 (unless you use your own Math implementation).