You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Kuketayev, Argyn (Contractor)" <ar...@fanniemae.com> on 2005/06/16 22:16:20 UTC
equal tag doesn't work with huge numbers
I believe that I reported this problem a year ago with Struts 1.1.
Struts logic:Equal tag can not compare properly large BigDecimal
numbers. It tries Double.valueOf() on the string, and it doesn't throw
any exceptions, so the tag assumes that the numbers are double. Consider
this number "300000000000000000000000000000001587", if you compare it to
"300000000000000000000000000000001588", Struts can't see they are
different. Here's a relevant snippet from CompareTagBase.java in Struts
1.2.7
protected boolean condition(int desired1, int desired2)
throws JspException {
// Acquire the value and determine the test type
int type = -1;
double doubleValue = 0.0;
long longValue = 0;
if ((type < 0) && (value.length() > 0)) {
try {
doubleValue = Double.parseDouble(value);
type = DOUBLE_COMPARE;
} catch (NumberFormatException e) {
;
}
}
I'm not sure what's the best way to fix this issue. One would be not to
try to convert to double or long at all.
Argyn
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
RE: equal tag doesn't work with huge numbers
Posted by James Holmes <ja...@jamesholmes.com>.
Can you open a bug in Bugzilla on this? If you could post a possible
solution (code) that would make it much more likely to get resolved too.
James
-----Original Message-----
From: Kuketayev, Argyn (Contractor) [mailto:argyn_kuketayev@fanniemae.com]
Sent: Thursday, June 16, 2005 3:16 PM
To: Struts Developers List
Subject: equal tag doesn't work with huge numbers
I believe that I reported this problem a year ago with Struts 1.1.
Struts logic:Equal tag can not compare properly large BigDecimal
numbers. It tries Double.valueOf() on the string, and it doesn't throw
any exceptions, so the tag assumes that the numbers are double. Consider
this number "300000000000000000000000000000001587", if you compare it to
"300000000000000000000000000000001588", Struts can't see they are
different. Here's a relevant snippet from CompareTagBase.java in Struts
1.2.7
protected boolean condition(int desired1, int desired2)
throws JspException {
// Acquire the value and determine the test type
int type = -1;
double doubleValue = 0.0;
long longValue = 0;
if ((type < 0) && (value.length() > 0)) {
try {
doubleValue = Double.parseDouble(value);
type = DOUBLE_COMPARE;
} catch (NumberFormatException e) {
;
}
}
I'm not sure what's the best way to fix this issue. One would be not to
try to convert to double or long at all.
Argyn
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org