Adding up BigDecimals using Streams
I have a collection of BigDecimals (in this example, a LinkedList) that I would like to add together. Is it possible to use … Read more
I have a collection of BigDecimals (in this example, a LinkedList) that I would like to add together. Is it possible to use … Read more
I have this little crazy method that converts BigDecimal values into nice and readable Strings. private String formatBigDecimal(BigDecimal bd){ DecimalFormat df = new … Read more
I’m trying to round BigDecimal values up, to two decimal places. I’m using BigDecimal rounded = value.round(new MathContext(2, RoundingMode.CEILING)); logger.trace(“rounded {} to {}”, … Read more
I have the following code in Java; BigDecimal price; // assigned elsewhere if (price.compareTo(new BigDecimal(“0.00”)) == 0) { return true; } What is … Read more
How can I compare if BigDecimal value is greater than zero? 7 Answers 7
I have to calculate some floating point variables and my colleague suggest me to use BigDecimal instead of double since it will be … Read more
Why does the following code raise the exception shown below? BigDecimal a = new BigDecimal(“1.6”); BigDecimal b = new BigDecimal(“9.2”); a.divide(b) // results … Read more