Re: BigDecimal, scale, and prototypes
Re: BigDecimal, scale, and prototypes
- Subject: Re: BigDecimal, scale, and prototypes
- From: David Avendasora <email@hidden>
- Date: Fri, 15 Aug 2008 12:09:43 -0400
On Aug 15, 2008, at 12:00 PM, David Avendasora wrote:
On Aug 15, 2008, at 11:38 AM, Florijan Stamenkovic wrote:
Hi all,
I am using BigDecimal in combination with WO for the first time,
and have some questions, perhaps someone with experience could
explain.
1. Is the scale of the resulting BigDecimal based on the scale of
the property as defined in the model?
Yes, I believe so. I use them all the time and I only run into
problems if I'm doing a math function where the result ends up with
too many decimal places. I then have to scale it manually before
assigning it to the attribute otherwise I get an exception. I've
thought about putting the scale function directly into the generated
setter method, but I haven't gone there yet.
Now that I think about it, it was the DB that was throwing the error,
not the Java code, so I'm changing my answer to "no".
2. Why does the currencyAmount wonder prototype has the scale of 4,
instead of 2? Easy to deal with, I am just wondering if there is a
specific reason for that...
How currency-centric of you. If you are selling widgets that are
really small, or you have a very strong currency, you may want to
keep track of a cost that is < .01 for calculations, even if the
value presented to the customer ends up getting rounded to 2 decimal
points. With some currencies you don't even need decimal points.
Colombian Peso, USD, etc.
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden