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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Passing Bigdecimals" Watch "Passing Bigdecimals" New topic
Author

Passing Bigdecimals

Anil Karamchandan
Ranch Hand

Joined: Sep 12, 2009
Posts: 47
Hi,

I am performing some mathematical operations on the numbers/currency given by the user. I am making use of big decimal's here. However when I try to return the calculated value via my ajax api it gives me a parseerror and thus I converted the bigdecimal to string and then for some very large values I get 4E1 , 6E+4 etc getting displayed .

Can any one let me know how could I avoild this ? or the best method to calcualte the currencies.

thanks !
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40041
    
  28
How are you displaying the BigDecimal?

And I don't think that code will compile because there aren't enough {}: please read this.
Anil Karamchandan
Ranch Hand

Joined: Sep 12, 2009
Posts: 47
hi,

The code does compile fine, this is the real code, I am using an SAAS application which has the provision of inserting your own code which complies once you save it. I am displaying my code on a text field of type currency, I also tried to change this to a normal textfield type but still I am not able to display it correctly. When I try to print the code once I have done some calculations for some of the fields it displays as 322222 10E calcs while for other it does not.

The point is how do I display bigdecimal on the screen for the user ? the field should be of which type ?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

The code doesn't compile because the functionality is not in a class and not in a function. Maybe something went wrong while copying it? I would recommend you to refactor this function into smaller functions, use generics for your HashMap and replace the magic numbers.

But we need more information to help you. So to repeat Campbell: How are you displaying the BigDecimal? Because currently you're only putting the bigDecimal.toString() into the HashMap.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
 
subject: Passing Bigdecimals