Question:
How to multiply a BigDecimal by an int in Java?
Multiplication with BigDecimals.
Multiplication with BigDecimals.
Answer:
bigdecimal.multiply(new BigDecimal(int))
Code:
import java.math.*; public class BigDecimalTest { public static void main(String[] args) { BigDecimal bd = new BigDecimal(2.0); int x = 5; bd = bd.multiply(new BigDecimal(x)); System.out.println(bd); } }
Output:
$ java BigDecimalTest 10