Interesting. Doesn't sound familiar. I don't have a Solaris box; a quick test on Windows indicates this isn't a difference between JDK 1.4 and JDK 1.5 - at least not on the Windows side. The sqrt is ultimately implemented in native code though, so implementations could be very different. The
bug database didn't seem to have any good match to what you describe - though it may well be worth looking through more carefully than I did.
I'm not familiar with Solaris architecture, but on Windows the sqrt would probably be evaluated by a math coprocessor (if available), right? So this could be some hardware difference between the two machines. It might be useful to run some other math benchmarks on the two machines. Is the Solaris box always a thousand times slower doing math? Or is it just for sqrt()?
It might also be nice to hear if these results hold up on other Solaris boxes, maybe with other JDKs. Does anyone here have one handy? Please try it let us know how sqrt() performs.
One possible workaround is to replace Math.sqrt(a) with Math.exp(Math.log(a)/2). This would normally be slower and less accurate, but it sure shouldn't me a thousand times slower, so maybe it will help. Or if exp() and log() are similarly slow on the Solaris box, but basic math operators are not, you could also try your own implementation of Newton's method - I
think that's (still?) the standard way to implement a sqrt() internally. Hmmm, maybe not -
Wolfram lists a few alternates; I'm not sure offhand which is fastest or most accurate. But if the problem is just with the sqrt() function, then any of those methods might be worth a try.
[ February 08, 2007: Message edited by: Jim Yingst ]