2006 IR Open Discussion Posted August 18, 2006 Share Posted August 18, 2006 By: N Kumar - kumarn3 Subtracting Variables 2003-04-07 06:45 Hi, Is there a way to subtract Variables? I want to do the following: $F{TOTAL} - ($F(COL1) + $F(COL2)) Thanks By: Gregory A. Swarthout - gswarthout RE: Subtracting Variables 2003-04-07 08:52 Ya, but since they are objects, you'd have to convert them to primitives first. If they were Integers, the code could look like this: new Integer($F{TOTAL).intValue() - ($F{COL1}.intValue() + $F{COL2}.intValue)) By: Gregory A. Swarthout - gswarthout RE: Subtracting Variables 2003-04-07 08:54 Ya, but since they are objects, you'd have to convert them to primitives first. If they were Integers, the code could look like this: new Integer($F{TOTAL).intValue() - ($F{COL1}.intValue() + $F{COL2}.intValue)) By: N Kumar - kumarn3 RE: Subtracting Variables 2003-04-07 15:12 Thanks , but the Variables are using class="java.math.BigDecimal" By: Adrian Jackson - iapetus RE: Subtracting Variables 2003-04-08 08:36 Then it's even easier. What you want is something like: $F{TOTAL}.subtract($F{COL1}).add($F{COL2}) It's all there in the Javadoc for BigDecimal... 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