Order of Magnitude of BigDecimal?

To check the number of correct decimal places you just want the order of magnitude of the difference, not the order of magnitude of the correct result. So I suppose you need to convert your double computed result to a BigDecimal subtract the precise result, then convert back to a double and take the logarithm in base 10 Or if you just need to check whether the result is accurate to x decimal places then just check if the difference is greater than 0.5 * 10^(-x), or equivalently: int x = 3; // number of decimal places required BigDecimal difference = accurateResult. Subtract(new BigDecimal(approxResult)); BigDecimal testStat = difference.

MovePointRight(x).abs(); boolean ok = testStat. CompareTo(new BigDecimal(0.5)) If you go that way I think you just have to explicitly round both numbers to x decimal places and then compare.

To check the number of correct decimal places you just want the order of magnitude of the difference, not the order of magnitude of the correct result. So I suppose you need to convert your double computed result to a BigDecimal, subtract the precise result, then convert back to a double and take the logarithm in base 10. Or if you just need to check whether the result is accurate to x decimal places then just check if the difference is greater than 0.5 * 10^(-x), or equivalently: int x = 3; // number of decimal places required BigDecimal difference = accurateResult.

Subtract(new BigDecimal(approxResult)); BigDecimal testStat = difference. MovePointRight(x).abs(); boolean ok = testStat. CompareTo(new BigDecimal(0.5)) You could say that 0.15001 and 0.24999 are equal to 1 decimal place (both round to 0.2) but that 0.19999 and 0.25001 are not even though the difference is smaller.

If you go that way I think you just have to explicitly round both numbers to x decimal places and then compare.

Since you seem to be interested only in a rough estimate: you should compare the log_10 of both values, which tells you the order of magnitude of you error... You can get a good approximation of log_10 of a BigInteger by looking at the length of its decimal representation toString(10).length().

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions