ts-7000
[Top] [All Lists]

[ts-7000] Corruption of Float values in Java

To:
Subject: [ts-7000] Corruption of Float values in Java
From: "tedapt" <>
Date: Thu, 13 Sep 2007 02:00:08 -0000
Hi,

I'm experiencing a problem with JamVM on a TS-7250 in which some float
values are corrupted.  

I can reproduce the problem if I run the following Java program:

public class Test {
   public static void main(String[] args){
      float a, b, c;
      a = 45f;
      b = 10f;
      c = a/b;
      System.out.println("" + c + " = " + a + "/" + b);
   }
}

   :root# /usr/bin/jamvm -cp . Test
   4.000007 = 45.0/10.0

As you can see, the result ought to be 4.5, not 4.000007.  With other
testing, I see odd float values, like ".005:389" for example.

I am using this version of JamVM:

   :root# jamvm -version
   java version "1.4.2"
   JamVM version 1.4.4

Executing the same code on a Windows JVM produce the correct result of
4.5.

Similarly, executing the following C program produces the correct
result, so the problem only manifests in Java:

void main(void) {

         float a,b,c;
         a=45.0;
         b=10.0;
         c=a/b;
         printf("%f=%f/%f\n",c,a,b);

}

   :root# gcc t.c -o t
   t.c: In function `main':
   t.c:1: warning: return type of `main' is not `int'
   :root# ./t
   4.500000=45.000000/10.000000

Any ideas?

Thanks very much,

Ted



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<Prev in Thread] Current Thread [Next in Thread>
  • [ts-7000] Corruption of Float values in Java, tedapt <=
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU