Top "Bigdecimal" questions

BigDecimal is a numeric object type in Java that represents decimal numbers with arbitrary precision.

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 …

java bigdecimal java-8 java-stream
Rounding Bigdecimal values with 2 Decimal Places

I want a function to convert Bigdecimal 10.12 for 10.12345 and 10.13 for 10.12556. But no function is satisfying both conversion in same time.…

java bigdecimal
How to round 0.745 to 0.75 using BigDecimal.ROUND_HALF_UP?

I tried the following, double doubleVal = 1.745; double doubleVal1 = 0.745; BigDecimal bdTest = new BigDecimal( doubleVal); BigDecimal bdTest1 = new BigDecimal( doubleVal1 ); bdTest = bdTest.…

java bigdecimal rounding
BigDecimal equals() versus compareTo()

Consider the simple test class: import java.math.BigDecimal; /** * @author The Elite Gentleman * */ public class Main { /** * @param args */ public static …

java equals bigdecimal compareto
How to multiply a BigDecimal by an integer in Java

How do you multiply a BigDecimal by an integer in Java? I tried this but its not correct. import java.…

java bigdecimal
Using BigDecimal to work with currencies

I was trying to make my own class for currencies using longs, but apparently I should use BigDecimal instead. Could …

java currency bigdecimal
Set specific precision of a BigDecimal

I have an XSD that requires me to use a BigDecimal for a lat/lon. I currently have the lat/…

java bigdecimal floating-point-precision
Convert Java Number to BigDecimal : best way

I am looking for the best way to convert a Number to a BigDecimal. Is this good enough? Number number; …

java numbers precision bigdecimal
How can I divide properly using BigDecimal

My code sample: import java.math.*; public class x { public static void main(String[] args) { BigDecimal a = new BigDecimal("1"); BigDecimal …

java bigdecimal
BigDecimal - to use new or valueOf

I came across two ways of getting BigDecimal object out of a double d. 1. new BigDecimal(d) 2. BigDecimal.valueOf(d) …

java bigdecimal