Cool.

BTW - I wonder if we need to check for Inf and other things as well.

Also, I suspect that FormatCmd.java might predate some of the
numerical format code in JDK1.1 java.text.NumberFormat

-Christopher
--------

    On Sun, 21 Mar 1999, Christopher Hylands wrote:
    
    > Jacl 1.1.1 prints out the wrong number when trying to handle NaN
    
    I added your patch to the 1.2.2 tree and it seems to be working just fine.
    I also added a test case to JavaFieldCmd.test and I put a revision
    note with your initials in the changes.txt file. This fix will be
    included in Jacl 1.2.2 with a minor change. Instead of creating
    a Double object I just called Double.isNaN(double) directly.
    
    --- FormatCmd.java      Mon Mar 22 19:04:13 1999
    +++ ../../src/jacl/tcl/lang/FormatCmd.java      Mon Mar 22 19:05:04 1999
    @@ -632,6 +632,9 @@
            // Normalize dblValue to within 10.0 > dblValue >= 1.0 
     
            exp = 0;
    +       if (Double.isNaN(dblValue)) {
    +           return "NaN";
    +       }
            if (dblValue>0.0) {
                int k = 0;
                while ((dblValue >= 1e8) && (k++ < 100)) {
    
    later
    mo
     
    > cxh@carson 50% uname -a
    > SunOS carson.eecs.berkeley.edu 5.5.1 Generic_103640-24 sun4u sparc SUNW,U
   ltra-2
    > cxh@carson 51% java -version
    > java version "1.2"
    > Classic VM (build JDK-1.2-V, green threads, sunwjit)
    > cxh@carson 52% setenv CLASSPATH jacl.jar:tcljava.jar 
    > cxh@carson 53% java tcl.lang.Shell
    > % java::field java.lang.Double NaN
    > 2147483647.21474836472147483647214748364721474836472147483647214748364721
   474836472147483647214748364721474836472147483647
    > % set java::patchLevel
    > 1.1.1
    > % 
    > 
    > The fix is to modify
    > src/jacl/tcl/lang/FormatCmd.java:
    > 
    > ***************
    > *** 683,688 ****
    > --- 683,691 ----
    >            */
    >   
    >           exp = 0;
    > +         if ((new Double(dblValue)).isNaN()) {
    > +             return "NaN";
    > +         }
    >           if (dblValue>0.0) {
    >               int k = 0;
    >               while ((dblValue >= 1e8) && (k++ < 100)) {
    > 
    > -Christopher
    > 
    > ----------------------------------------------------------------
    > The TclJava mailing list is sponsored by WebNet Technologies.
    > 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]'. 
    > A list archive is at: http://www.findmail.com/listsaver/tcldallas/
    > 
    
    ----------------------------------------------------------------
    The TclJava mailing list is sponsored by WebNet Technologies.
    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]'. 
    A list archive is at: http://www.findmail.com/listsaver/tcldallas/
--------

----------------------------------------------------------------
The TclJava mailing list is sponsored by WebNet Technologies.
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]'. 
A list archive is at: http://www.findmail.com/listsaver/tcldallas/

Reply via email to