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

Comparing BigDecimal values, help!!


saman0suke

Recommended Posts

Hello, I'm trying to make a comparison here, so if the doc is equal to "1" it will print the result in a color, and if it's the other one, in a different one, but I'm getting this error:

The left-hand side of the assignment must be a variable

And here's the code:

(new BigDecimal($F{document}).compareTo(new BigDecimal(1))=new BigDecimal(1)? "<style forecolor='#006633'>" + $F{total} + "</style>": (new BigDecimal($F{document}).compareTo(new BigDecimal(2))=new BigDecimal(2)? "<style forecolor='#ff0000'>" + $F{total} + "</style>": $F{total} ))

Could you point me in the right direction? thanks!

 

EDIT: I just found out that one of the problems lies here:

"<style forecolor='#006633'>" + $F{total} + "</style>"

ireport says that there's some incompatibility because I'm declaring "strings" and comparing BigDecimal,  I managed to make it work, but without those tags, is there any way to solve it? thanks!

 



Post Edited by saman0suke at 01/08/2011 17:53
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Well, I don't have it with me right now but let me give you that information:

 

document is String, so that's why I convert it to BigDecimal

total is BigDecimal.

 

I checked again and the problem is the style tags, because it's giving me all the time the: "Cannot cast from string to bigDecimal" like it's recognizing the tags as part of the value that is going to be entered into the Field. By the way the target Field is BigDecimal, because the $total is BigDecimal on the select, thanks!

Link to comment
Share on other sites

If you are using iReport, I would suggest compile the report. It will give you compile time error in 'Report Problem Window' . You can double click on that error and find out where exactly is the type mismatch.

 

I am not sure if above suggestion will work in your case. But it did work for me once.

Link to comment
Share on other sites

probably this is whats wrong:

new BigDecimal($F{document}).compareTo(new BigDecimal(1))=new BigDecimal(1)

should be

new BigDecimal($F{document}).compareTo(new BigDecimal(1))==1 ? ..

there is another similar expression, you should change that one too..

 

 

 

Link to comment
Share on other sites

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...