Okay, I (finally) agree with you. Thanks for the explanations.
Mark
-Original Message-
From: Richard Yee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 01, 2002 1:35 PM
To: Struts Users Mailing List
Subject: RE: Bean Bug?
Mark,
Regardless of how the number is formatted
Please respond to Struts Users Mailing List [EMAIL PROTECTED]
To:'Struts Users Mailing List' [EMAIL PROTECTED]
cc:
Subject:RE: Bean Bug?
I'd be interested in how you can use ints for decimal numbers. The right
way is to use BIG_DECIMAL, but I have to use the session bean method given
me
I see your point, but aren't you incurring unnecessary formatting overhead
in the presentation tier (to say nothing of ongoing maintenance)? Any
Struts tag that writes to the presentation tier should take such formatting
issues into consideration. For example, the formatting tag that Chandras
Mark,
Regardless of how the number is formatted, there will always be a problem
when handling currency amounts as floating numbers. Multiplication and
division operations will introduce rounding errors. I have found that it is
best to store currency amounts as ints and then have code in the
this
kind of formatting. I think this is what Mark is asking about.
-Original Message-
From: Richard Yee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 01, 2002 12:35 PM
To: Struts Users Mailing List
Subject: RE: Bean Bug?
Mark,
Regardless of how the number is formatted, there will always
think this is what Mark is asking about.
-Original Message-
From: Richard Yee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 01, 2002 12:35 PM
To: Struts Users Mailing List
Subject: RE: Bean Bug?
Mark,
Regardless of how the number is formatted, there will always be a problem
when handling
The java.math.BigDecimal class gives its user complete control over rounding
behavior.
Mark
-Original Message-
From: Richard Yee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 01, 2002 1:57 PM
To: Struts Users Mailing List
Subject: RE: Bean Bug?
Chandra,
I think the point I am trying
First Principle of Economics: ever use float or double for money. Use
ints. Or, for serious money, longs. 'The real problem is not the output
but the whole idea.
micael
At 05:56 PM 4/30/02 -0400, you wrote:
I'm using a simple bean:write name=phone property=price / which grabs
a float price
I'd be interested in how you can use ints for decimal numbers. The right
way is to use BIG_DECIMAL, but I have to use the session bean method given
me for my bean data. But this still does not address the issue of the
bean:write behavior.
Mark
-Original Message-
From: Micael Padraig
, 2002 6:15 PM
Subject: RE: Bean Bug?
I'd be interested in how you can use ints for decimal numbers. The
right
way is to use BIG_DECIMAL, but I have to use the session bean method given
me for my bean data. But this still does not address the issue of the
bean:write behavior.
Mark
Maybe not the best approach but I'd add another form bean field as a
String called priceDisplay
Then in the setPrice(float f) method you'd call setPriceDisplay(float
f)
setPriceDisplay( float money ) {
DecimalFormat df = (DecimalFormat)NumberFormat.getCurrencyInstance();
Thanks - I'll give it a whirl.
-Original Message-
From: Otavio Decio [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 6:38 PM
To: Struts Users Mailing List
Subject: Re: Bean Bug?
Don't know if this is your problem, but try to put the following in your
resources file
, Mark [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 5:15 PM
To: 'Struts Users Mailing List'
Subject: RE: Bean Bug?
I'd be interested in how you can use ints for decimal numbers. The right
way is to use BIG_DECIMAL, but I have to use the session bean method given
me for my bean data
Mark,
To store decimal numbers or any currency for that matter as ints, you store
the values as the smallest unit of currency. For dollars, this is 0.01 or
a cent. You then can avoid any round off errors when doing multiplication
or division.
Regards,
Richard
At 06:15 PM 4/30/2002 -0400,
Mark,
In continuing with my last email. 1.00 would be stored as 100 in an int.
-Richard
At 03:52 PM 4/30/2002 -0700, you wrote:
Mark,
To store decimal numbers or any currency for that matter as ints, you
store the values as the smallest unit of currency. For dollars, this is
0.01 or a cent.
15 matches
Mail list logo