Jump to content
Changes to the Jaspersoft community edition download ×

how to set 2 decimal double variable?(URGENT)


ts_chung

Recommended Posts

hi.

i got a problem.

my Double $F{field} could be more than 2 decimal and to display it is no problem as i can use the pattern to format it.

however, i need to sum the double $F{field} and the result should be exactly same as display in each field.

my question is, how can i sum the $F{field} into a variable with exact 2 decimal???

i am currently using ireport 0.5.3

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

If you want consider only the first 2 decimals, of a number, you can multiply the number per 100, take the integer part and divide it again:

 

Suppose TEST is a Double with a primitive value of 1.2345

 

you have to sum the following value:

 

new Double( ((int)($P{TEST}.doubleValue() * 100)) / 100.0 )

 

If effect if you print this value, you'll get 1.2300

(use 4 decimals in the pattern to be sure)

 

Giulio

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