1. Learn
  2. /
  3. Courses
  4. /
  5. Data Types and Exceptions in Java

Connected

Exercise

Using math classes

Classes from java.math can be a bit more challenging to work with, but offer the ability to work with larger numbers and are more precise. In this exercise, you'll see the precision difference between a double and a BigDecimal from java.math.

Instructions

100 XP
  • Import the BigDecimal class from java.math.
  • Create an instance of BigDecimal to hold the number 9.123456789.
  • Multiply the BigDecimal in variable bigDec by ten.
  • Divide the BigDecimal in variable bigDec by hundred.