• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BigDecimal - am I missing something obvious?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following code:

BigDecimal smallPercent = new BigDecimal (20.2);
EquipmentContributionDeclaration anEquiContDecl =
new EquipmentContributionDeclaration();
anEquiContDecl.setContributionPercentage(smallPercent);
System.out.println(anEquiContDecl.getContributionPercentage().toString());

Where contributionPercentage is an attribute of type BigDecimal in the EquipmentContributionDeclaration class.

It seems like the getter and setter should work in the usual way, but the result of the println is 0. Just plain 0.

Is there something mysterious or esoteric about BigDecimal that I am missing?

Thanks.

Dorcas
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dorcas Rebanha:
It seems like the getter and setter should work in the usual way

You would think so. But the mystery is more likely to be in the details of the getter and setter. Have a look there first.
 
Dorcas Rebanha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. Others on my team narrowed it down to a mysterious problem with the setter. It's not my job to pursue that problem, but others will do so.

Dorcas
 
Your mother is a hamster and your father smells of tiny ads!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic