on 01-31-2012 6:43 PM
Hi,
We are looking for a UDF to sum sign numbers.
Example,
String[] Amount={"00000000013.20","000000000017.56","00000000013.20-","000000000017.56-"};
Output = 13.20 + 17.56 - 13.20 - 17.56.
Any help is appreciated.
-santosh.
Hi, try out the standard function sum that calculates the Sum of values X1 to Xi of a context. You find it in the Function Category: Statistics.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
here's the code,
you have to adapt it to work a bit on pi.
public static String sum(String[] amount){
double res=0;
for (int i=0;i<amount.length;i++){
String local = amount<i>;
if (local.contains("-"))
res-=Double.parseDouble(local.replace("-",""));
else
res+=Double.parseDouble(local.replace("+",""));
}
return Double.toString(res);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.