views:

186

answers:

2

iam having problem with assigning one big decimal value to another

so i am trying such as creating one temp big decimal and add 0 to another big decimal

BigDecimal temp = new BigDecimal(0);
dropStartValue =  temp.add(newCounterValue);

i only want simply do the operation below on big decimals

dropStartValue = newCounterValue
+1  A: 

You haven't specified the type of either dropStartValue or newCounterValue. If they're both BigDecimals, then this should be fine:

dropStartValue = newCounterValue;

Note that although that's just making both variables refer to the same object, it's safe because BigDecimal itself is immutable.

If that's not working for you, please give details of what problems you're seeing (exceptions? compile-time errors?).

Jon Skeet
And for the OP, some documentation: http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html
T.J. Crowder
A: 

Assuming this is Java ans newCounterValue is an integer type or a box thereof, dropStartValue = new BigDecimal(newCounterValue); should do what you want.

Romain
I thought that originally - but BigDecimal.add doesn't take ints etc, so I suspect newCounterValue is another BigDecimal...
Jon Skeet
@Jon: Sure it does: http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html#BigDecimal(int)
T.J. Crowder