• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in taking difference between two long number.

 
Nagendra Batchu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The above two outputs are coming in a single Upload Transaction
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rimaryForm.getSeriesTo()--------->90000258004511
primaryForm.getSeriesFrom()--------->90000258800001
The totalQty--------------------->-795489


it's because the seriesFrom number is greater than the seriesTo number ;-)
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic