Jump to content
We've recently updated our Privacy Statement, available here ×

int to BigDecimal


spmkkmps

Recommended Posts

Hi

In my application there is a field "Period" of type BigDecimal. i need to check for a condition like,

($F{Period} != 0)?value1:value2

but it says, Incompatible operand types BigDecimal and int

 

and  another condition like,

($F{Period} < 0)?value1:value2

but 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

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

  • 4 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...