Java BigDecimal to BigInteger

In this post, we will see how to convert BigDecimal to BigInteger in java.

Using BigDecimal constructor

You can simply use BigDecimal's toBigInteger() method to convert BigDecimal to BigInteger.

Please note that this method will simply remove fractional part and you will loss precision while converting from BigDecimal to BigInteger in java.

Here is the complete example to convert BigDecimal to BigInteger in java.

When you run above program, you will get below output:

BigDecimal bd: 10

That’s all about how to convert BigInteger to BigDecimal in java.

Related Posts

  • Java BigDecimal to Double
    17 May

    Java BigDecimal to Double

    Learn about how to convert BigDecimal to Double in java

  • 19 December

    Java BigInteger to BigDecimal

    In this post, we will see how to convert BigInteger toBigDecimal in java. Using BigDecimal constructor You can simply use BigDecimal’s following constructor to convert BigInteger to BigDecimal. BigDecimal(BigInteger val) Here is the complete example to convert BigInteger to BigDecimal in java. [crayon-60f47c4b07868264182343/] When you run above program, you will get below output: BigDecimal bd: […]

  • 14 December

    BigDecimal divide

    Table of ContentsSyntaxReturn typeBigDecimal round example In this tutorial we will see about BigDecimal‘s divide method. BigDecimal’s divide method is used to divide one BigDecimal by another. You can specify scale and rounding mode to get the output according to your need. There are 6 overloaded versions of divide method. Syntax [crayon-60f47c4b09647714324758/] Return type returns […]

  • 14 December

    BigDecimal round

    Table of ContentsSyntaxReturn typeBigDecimal round exampleBigDecimal setScale method In this tutorial, we will see about BigDecimal‘s round method. BigDecimal’s round method is used to round the BigDecimal based on MathContext setting. Syntax [crayon-60f47c4b0a09e467152098/] Return type returns BigDecimal rounded with MathContext setting BigDecimal round example Let’s understand BigDecimal method with the help of example [crayon-60f47c4b0a0a4866055491/] Above […]

  • 12 October

    Java BigDecimal

    Table of ContentsConstructorsMethodsFAQsHow can you compare two BigDecimals?How to set scale in case of BigDecimalsHow to convert String to BigDecimal?How to convert BigDecimal to String?How to add two BigDecimals in java?How to subtract two BigDecimals in java?How to multiply two BigDecimals in java?How to divide two BigDecimals in java?How to remove trailing zero from BigDecimal? […]

  • 05 October

    Java BigDecimal to String

    Table of ContentstoString methodString’s ValueOf methodIssues with toString In this post, we will see how to convert BigDecimal to String in java. There are many ways to convert BigDecimal to String in java. Some of them are: Using toString() Using String.valueOf() toString method You can simply use BigDecimal’s toString method to convert BigDecimal to String. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.