spmkkmps Posted July 9, 2009 Share Posted July 9, 2009 HiIn my application there is a field "Period" of type BigDecimal. i need to check for a condition like,($F{Period} != 0)?value1:value2but it says, Incompatible operand types BigDecimal and int and another condition like,($F{Period} < 0)?value1:value2but it gives me the following error,the operator < is undefined for the argument type(s) BigDecimal, int Can you please tell me what needs to be changed in my syntax. Please post your answers soon. Its very urgent. Thanks a lot. Madhan!!!! Link to comment Share on other sites More sharing options...
baggypants Posted July 9, 2009 Share Posted July 9, 2009 Try ($F{Period} != new BigDecimal(0))?value1:value2 I'm new at this Java thing so it may not work Link to comment Share on other sites More sharing options...
mdahlman Posted July 9, 2009 Share Posted July 9, 2009 No, operators like "not equal" don't work on objects like that. Rather than converting zero to a BigDecimal, you probably need to go the other way: convert the BigDecimal to an int. Like this: ($F{Period}.intValue() < 0)?value1:value2 Regards,Matt baggypants's idea could also work, but it's probably more difficult. It would be more like this:($F{Period}.compareTo(new BigDecimal(0)) != 0) ? value1 : value2 Link to comment Share on other sites More sharing options...
jafarcs01 Posted January 18, 2014 Share Posted January 18, 2014 TryBigDecimal secondNum = new BigDecimal(0);if($F{Period}.compareTo(secondNum)>0)) Regards,Jaf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now