on 04-23-2009 5:47 AM
Hi there
I have some values that I need to add up but it is too big for a normal double value. How do I manage around this? The values can be negative or positive and can go up to $99 999 999 999.99. I have a context array that I need to loop through and add up these values.
Thanks,
Jan
Got it working.
BigDecimal d1 = new BigDecimal(value);
BigDecimal d2 = d1.setScale(2, BigDecimal.ROUND_HALF_DOWN);
result.addValue(d2+"");
Cheers,
Jan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi again
The decimal is not really my issue, I can loop through the string values, parse it to Double and add them up but when I convert it back to a string I get something like
3.450041159E7 or -3.450041159E7
How do I change this to be a normal string?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The basic ·value space· of double consists of the values m × 2^e, where m is an integer whose absolute value is less than 2^53, and e is an integer between -1075 and 970, inclusive. In addition to the basic ·value space· described above, the ·value space· of double also contains the following three special values: positive and negative infinity and not-a-number (NaN)
2^53 = 9.00719925 × 10^15
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use formatNumber standard Function. and take 11 '0's and 2 decimals.and decimal separator as ' . '
like
input---------------formatNumber[00000000000.00]--------------output
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
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.