ts_chung Posted July 19, 2006 Share Posted July 19, 2006 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 More sharing options...
Giulio Toffoli Posted July 19, 2006 Share Posted July 19, 2006 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 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