• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Passing Bigdecimals

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !
 
Marshal
Posts: 79707
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
The fastest and most reliable components of any system are those that are not there. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic