Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2008

Tip: Looking for answers? Try searching our database.

classpath-0.92+floats+patch+arm

Thread view: 
grp62 - 04 Mar 2008 15:10 GMT
Hello,
I encountered some problems when i tried to use the float type on my
embedded board based on arm926ejs core.
Indeed with the following code:
/
************************************************************************/
public class helloworld{
    public static void main(String argv[]){
        double dvar = 0.1;
        float fvar = 0.1f;
        System.out.println("Hello\n");
        System.out.println("\nboth of these should be 0.1:");
        System.out.println("double var = " + dvar);
        System.out.println("float var = " + fvar);

        System.out.println("\ndouble size = " + Double.SIZE);
        System.out.println("float size = " + Float.SIZE);

        System.out.println("\n");
    }
}
/
************************************************************************/
Here's what i get when i issue the following command:
# jamvm helloworld
Hello

both of these should be 0.1:
double var = 0.00000103455646584
float var = 0.0004:3256

double size = 64
float size = 32

After some researches i found a patch about the arm float parsing
http://www.mail-archive.com/classpath-patches@gnu.org/msg08956.html

It seems to correct the problem, but is there someone who can explain
exactly the problem ?
On the other hand, i'd like to understand how the floats are managed
into the java code.
Since my hardware does not embed a FP unit and the linux kernel is
disabled how the float are processed ?
regards
greg
Roedy Green - 05 Mar 2008 08:20 GMT
>float var = 0.0004:3256

In standard Java you may not embed colons in the middle of numbers.

floats also must end with f.

float var = 0.0003256f;

"var" is a bad choice of variable name. It tells you nothing about
about the purpose. It also masquerades as a keyword.  It is a keyword
in Pascal.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Lew - 05 Mar 2008 12:57 GMT
> "var" is a bad choice of variable name. It tells you nothing about
> about the purpose. It also masquerades as a keyword.  It is a keyword
> in Pascal.

Pascal?  Really?  You're objecting on the basis of a conflict with Pascal?

Signature

Lew

Roedy Green - 06 Mar 2008 12:50 GMT
>Pascal?  Really?  You're objecting on the basis of a conflict with Pascal?

On general principles I object to variable names that remotely look
like keywords.

var IS a keyword is some languages.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Roedy Green - 05 Mar 2008 08:29 GMT
>System.out.println("float var = " + fvar);

Looks like a bug.  Try explicitly converting float to String.
See http://mindprod.com/applet/converter.html
for how.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.