on 03-17-2010 2:38 PM
Hi,
we have one UDF to calculate the price .The sample code for this UDF is ..
BigDecimal Value = new BigDecimal(Inputvalue);
If Curr = 'EUR' {
try {
while (true) {
Value = Value.setScale(Value.scale()-1);
}
} catch (ArithmeticException e) {
}
}
This UDF is working fine for all the value except multiples of 10.
For 10.00000 it's returning 1E +1
for 500.00000 it's returning 5E +2
Can someone help me to get correct values for multiples of 10 also.
Thanks,
Bharath.
> Value = Value.setScale(Value.scale()-1);
> This UDF is working fine for all the value except multiples of 10.
This is just what you have coded.
http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> BigDecimal Value = new BigDecimal(Inputvalue);
> If Curr = 'EUR' {
> try {
> while (true) {
> Value = Value.setScale(Value.scale()-1);
> }
> } catch (ArithmeticException e) {
> }
> }
>
> This UDF is working fine for all the value except multiples of 10.
> For 10.00000 it's returning 1E +1
> for 500.00000 it's returning 5E +2
I see an infinite loop there for setting the scale..!! Was that intended? Every time you are decreasing the scale by one value. Instead why dont you call it once and set the scale to the number of digits you want after the decimal?
VJ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.