开发者

BigDecimal assign operator

I have a problem with assigning one big deci开发者_如何学编程mal 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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜