Question

I have a problem with assigning one big decimal value to another

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);

However, I only want simply do the operation below on big decimals:

dropStartValue = newCounterValue
Was it helpful?

Solution

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?).

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top