On Fri, 18 Feb 2000, Vince Darley wrote:

> I reported a problem with this some time ago, and have now tracked it down.
> Not sure if it's a bug or not (I certainly couldn't find -1.#IO documented
> anywhere as the java string representation of -infinity), but basically it's
> a result of divide by zero:
> 
> public class Test {
>     public static double test(int a, int b) {
>       return ((double)a)/(480.0+(double)b); 
>     }
> }
> 
> make Test available to tclblend
> 
> % java::call Test test 1000 -480
> 1.#IO
> % java::call Test test -1000 -480
> -1.#IO
> 
> Hope that helps someone else avoid the problem.  In my case this means
> there's a bug in my code which leads to the wrong 'b' value above...
> 
> cheers,
> 
> Vince.

Yeah, this is one of those really nasty areas of the JVM that do
not seem to be documented. Different JVMs on different platforms
return different things. Check out this nasty test case from
tcljava/tests/tcljava/JavaFieldCmd.test.

test javaFieldCmd-6.7 {test -Inf} {
    set result [java::field java.lang.Double NEGATIVE_INFINITY]
    set result [string trim $result]

    if {[string compare $result -Inf] == 0 || \
            [string compare $result -Infinity] == 0 || \
            [string compare $result -inf] == 0 || \
            [string compare $result -1.#INF] == 0} {
        set result pass
    } else {
        set result [list fail $result]
    }

    set result
} pass


Yuk!

Mo Dejong
Red Hat Inc.


----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to