aspose file tools*
The moose likes Java in General and the fly likes Number Conversion Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Number Conversion Problem" Watch "Number Conversion Problem" New topic
Author

Number Conversion Problem

Anand Karia
Ranch Hand

Joined: Sep 25, 2004
Posts: 156

Dear All.

I am using JTable having values in column 3.
I am getting values from it using jTable.getValueAt(1,1).toString;
Then i use Double/Float/Integer/Long etc to convert data.
My data having values 999,999,999,999.99
Problem is that thru any of above option i get 9.9999999999999
in sum of different values. My jTable contents number of values positive and negative.

Can anyone help me where i m wrong or is there any other way to solve my this problem.

I am using the same below method except Double.parseDouble(), Integer.parseInt() etc etc



Love is GOD and GOD is Love.
Anand Karia
IT Concretor.......
M/s. Anand Karia Concreting IT
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
The problem is that the parse methods of Double, etc. all assume the String has no formatting elements excpet . Since yours does, you should use DecimalFormat to parse String values with , seperators.
http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number Conversion Problem