aspose file tools*
The moose likes Java in General and the fly likes Problem in taking difference between two long number. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem in taking difference between two long number." Watch "Problem in taking difference between two long number." New topic
Author

Problem in taking difference between two long number.

Nagendra Batchu
Ranch Hand

Joined: Jan 23, 2008
Posts: 32
Hi Friends,

I have to Upload a file where we will have two 14 digit number called fromNumber and toNumber , so i assigned those two numbers to long datatype.

when i upload a large number of file say(5 lakhs records), at that time, to some of the records are coming with minus number (this happends only for some number)

Could any one help me in solving this problem,

The code is:-----
primaryForm.setSeriesFrom(Long.parseLong(CSVData[4].trim()));
primaryForm.setSeriesFrom(Long.parseLong(CSVData[5].trim()));

System.out.println("primaryForm.getSeriesTo()--------->"+primaryForm.getSeriesTo());
System.out.println("primaryForm.getSeriesFrom()--------->"+primaryForm.getSeriesFrom());
long totalQty=(primaryForm.getSeriesTo()-primaryForm.getSeriesFrom()) ;
System.out.println("The totalQty--------------------->"+Long.toString(totalQty));


the output which is not working is:

primaryForm.getSeriesTo()--------->90000258004511
primaryForm.getSeriesFrom()--------->90000258800001
The totalQty--------------------->-795489


The output which is working fine :

primaryForm.getSeriesTo()--------->90000000972015
primaryForm.getSeriesFrom()--------->90000000962016
The totalQty--------------------->10000




Nagendra Batchu
Ranch Hand

Joined: Jan 23, 2008
Posts: 32
The above two outputs are coming in a single Upload Transaction
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
rimaryForm.getSeriesTo()--------->90000258004511
primaryForm.getSeriesFrom()--------->90000258800001
The totalQty--------------------->-795489


it's because the seriesFrom number is greater than the seriesTo number ;-)


JDBCSupport - An easy to use, light-weight JDBC framework -
 
Don't get me started about those stupid light bulbs.
 
subject: Problem in taking difference between two long number.