Java Bigdecimal

Learn how to Java BigDecimal class with example. We have provided almost all the examples of BigDecimal class.

Java Bigdecimal

Learn how to Java BigDecimal class with example. We have provided almost all the examples of BigDecimal class.

Java Bigdecimal

Java Bigdecimal

examples and code: Learn how to Java BigDecimal class with example. We have provided almost all the examples of BigDecimal class.

The BigDecimal class is used to manipulate and rounding the floating point numbers. The BigDecimal class helps the programmer to obtain the accurate decimal results in the business applications requiring higher degree of accuracy.

Programmers are using BigDecimal class in business application to process the floating point numbers. Here is the example programs of BigDecimal class.

Feel free to browse the BigDecimal examples given below:

     

  1. Java BigDecimal floatValue method example
    Java bigdecimal class floatValue() method translates bigdecimal value in to float type value. Method throws  NumberFormatException if it finds value other than a integer or float .
      
  2. In this example Java bigdecimal class divide (BigDecimal divisor, MathContext mc) method working is demonstrated. This method divides this.object value by the specified object value & returns quotient as per defined context settings
     
  3. Java BigDecimal compareTo example
    BigDecimal class compareTo() method analyzes this.object value with the specified object value  numerically. This means method numerically compares the value of the object on which it is invoked, with the value of the mentioned object.
      
  4. Java BigInteger long
    Example below illustrates the bigdecimal class divide(BigDecimal divisor) method working. In the example method divides the bigdecimal object value in which it is invoked by the bigdecimal object value passed inside its parentheses.
      
  5. Java Bigdecimal class example
    Java bigdecimal class comes under java.math library. Class bigdecimal enhances the users limitation over rounding action on numbers by providing a set of eight rounding modes such as ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, etc.
      
  6. Java BigDecimal byteValueExact example
    With this example, working of byteValueExact() method in getting exact byte value from a bigdecimal object is demonstrated. This method transfigures(changes) a bigdecimal object value into a byte data type value.
      
  7. Java BigDecimal add example
    In this example working of .add() method is demonstrated in following two constructor forms add(BigDecimal augend) and add(BigDecimal augend, MathContext mc) respectively.
      
  8. Java BigDecimal abs example
    Example below shows working of .abs() method of bigdecimal class. Method always returns absolute values. Here it returns the absolute values of bigdecimal class objects big_0 & big_1 respectively.
      
  9. Java BigDecimal longValueExact example
    Java bigdecimal class longValueExact() method transforms bigdecimal value exactly in to exact long type values. Method throws NumberFormatException if it value other than a integer or double.
     
  10. Java BigDecimal longValue example
    Java bigdecimal class longValue() method transforms bigdecimal value exactly in to long type values. Method throws NumberFormatException if it finds a String bigdecimal  value instead of a integer or double value.
      
  11. Java BigDecimal intValueExact example
    Java bigdecimal class intValueExact() method transforms bigdecimal value exactly in to integer type values. Method throws NumberFormatException if it value other than a integer or double.
     
  12. Java BigDecimal intValue example
    Java bigdecimal class intValue() method transforms bigdecimal value in to integer type values. Method throws NumberFormatException if it finds value other than a integer or double.
     
  13. Java BigDecimal hashCode example
    In this example bigdecimal class hashCode() method working is shown. Method returns integer values, both negative & positive. For every number method generates different hash codes.
      
  14. Java BigDecimal equals example
    Method evaluates bigdecimal object values as well as the scales allocated to the values. Method returns true only when both bigdecimal objects as operands for the methods possess same value and same scale. 
      
  15. Java BigDecimal doubleValue example
    Java bigdecimal class doubleValue() method translates bigdecimal value in to double type value. Method throws NumberFormatException if it finds a String bigdecimal value instead of a integer or double value.
     
  16. Java BigDecimal divideToIntegral method example
    In this example working of divideToIntegral(BigDecimal divisor, MathContext mc) method is shown. Method divides the bigdecimal class object value on which it is invoked, by the bigdecimal class object value passed inside the parentheses of the method.
      
  17. Java BigDecimal divideToIntegral example
    In this example working of divideToIntegral(BigDecimal divisor) method is shown. Method divides the bigdecimal class object value on which it is invoked, by the bigdecimal class object value passed inside the parentheses of the method.
      
  18. Java BigDecimal divide examples
    In this example, Java bigdecimal class divide(BigDecimal divisor, int scale, int roundingMode) method working  is demonstrated. Example contains scale feature which is an integer type value that defines number of digits after decimal.
      
  19. Java BigDecimal divideAndRemainder method example
    In the example method of divideAndRemainder(BigDecimal divisor, MathContext mc) returns 'quotient'  as per context settings defined in MathContext class object 'mc'. 
     
  20. Java BigDecimal divideAndRemainder example
    Example below demonstrates, working of divideAndRemainder(BigDecimal divisor) method. Method divides the bigdecimal  class object value on which it is invoked, by the bigdecimal class object value passed inside the parentheses of the method. 
      
  21. Java bigdecimal max example
    Example below demonstrates the working of bigdecimall class max() method. Java max method analysis the bigdecimal objects value and returns the numerically maximum value.
     
  22. Java bigdecimal min example
    Example below demonstrates the working of bigdecimal class min() method. Java min method analysis the bigdecimal objects value and returns the numerically minimum value.
      
  23. Java bigdecimal movePointLeft example
    Example below demonstrates bigdecimal class movePointLeft method example. Method returns a bigdecimal object value. Method moves the decimal point also called dot operator(.) towards left side of the number.
     
  24. Java BigDecimal movePointRight example
    Example below demonstrates bigdecimal class movePointRight method example. Method returns a bigdecimal object value. Method moves the decimal point also called dot operator(.) towards right side of the number.
      
  25. Java bigdecimal multiply example
    Example below demonstrates bigdecimal class multiply method example. Method returns a bigdecimal object value. Method multiply  this.object value with the value of the specified object.
     
  26. Java bigdecimal multiply method example
    Example below demonstrates bigdecimal class multiply method example. Method returns a bigdecimal object value. Method multiply  this.object value with the value of the specified object. Scale of the result will be as per context settings.
      
  27. Java bigdecimal negate example
    Example below demonstrates working of bigdecimal class negate method. Method returns a bigdecimal value of nature just opposite of the nature that the same value possess previously.
      
  28. Java bigdecimal negate method example
    Example below demonstrates working of bigdecimal class negate method. Method returns the same copy of the bigdecimal value but with opposite nature, that the bigdecimal value possess previously.
     
  29. Java bigdecimal plus example
    Example below demonstrates working of bigdecimal class plus method. Method always returns a bigdecimal value of positive nature. In short method return type is plus of this.object or simply +this.object.
     
  30. Java bigdecimal plus method example
    Example below demonstrates working of bigdecimal class plus method. Method always returns a bigdecimal value of positive nature as per context settings defined.
     
  31. Java bigdecimal pow example
    Example below demonstrates working of bigdecimal class pow method. Method returns a bigdecimal value (to the power n)  i.e. (this.object) to the power n.
     
  32. Java bigdecimal pow method example
    Example below demonstrates working of bigdecimal class pow method. Method returns a bigdecimal value (to the power n) i.e. (this.object )(to the power n) as per context settings.
      
  33. Java bigdecimal precision example
    In this example, bigdecimal class precision method working is demonstrated. Method return type is int. Method returns the number of  digits of an unscaled object value.
     
  34. Java bigdecimal remainder example
    In this example, bigdecimal class remainder method working is demonstrated. Method return type is a bigdecimal value. Method returns remainder i.e. this.object %  object specified.
     
  35. Java bigdecimal remainder method example
    In this example, bigdecimal class remainder method working is demonstrated. Method returns a bigdecimal  value as per context settings.
      
  36. Java bigdecimal round example
    In this example, bigdecimal class round method working is demonstrated. Method return type is a bigdecimal value as per context settings. 
      
  37. Java bigdecimal scale example
    In this example, bigdecimal class scale method working is demonstrated. Method return type is int therefore it generates only integer value.
      
  38. Java bigdecimal scaleByPowerOfTen example
    In this example, bigdecimal class bigdecimal method working is demonstrated. Method return type is a bigdecimal value therefore it generates only bigdecimal object values.
      
  39. Java bigdecimal setScale example
    In this example, bigdecimal class setScale method working is demonstrated. Method return type is a bigdecimal value therefore it generates only bigdecimal object values.
     
  40. Java bigdecimal setScale method example
    In this example, bigdecimal class setScale method working is demonstrated. Method return type is a bigdecimal value therefore it generates only bigdecimal object values.
      
  41. Java bigdecimal valueOf long method
    Example below demonstrates working of bigdecimal class valueOf method. Method returns bigdecimal values.  Method converts the long values in to bigdecimal value.
     
  42. Java bigdecimal valueOf long example
    Example below demonstrates working of bigdecimal class valueOf method. Method returns bigdecimal values.  Method converts the long values in to bigdecimal value.
      
  43. Java bigdecimal valueOf double example
    Example below demonstrates working of bigdecimal class valueOf  method. Method returns bigdecimal values.  Method converts the double value in to bigdecimal value.
      
  44. Java bigdecimal unscaledValue example
    Example below demonstrates working of bigdecimal class unscaledValue method. Method returns biginteger values.  An un scaled value of  the bigdecimal object  is returned as biginteger object value.
     
  45. Java bigdecimal ulp example
    Example below demonstrates working of bigdecimal class ulp method. Method returns  bigdecimal values.  Method returns the size of an ulp. which is the size of a unit at the last place of the bigdecimal object value. 
      
  46. Java bigdecimal toString example
    Example below demonstrates working of bigdecimal class toString method. Method return type is string therefore method returns string value only. This bigdecimal class toString method generates, string representation of the bigdecimal object value .
      
  47. Java bigdecimal toPlainString example
    Example below demonstrates working of bigdecimal class toPlainString method. Method return type is string therefore method returns string value only.
      
  48. Java bigdecimal toEngineeringString example
    In this example working of  Java bigdecimal class toEngineeringString method  is demonstrated.  Method return type is string therefore it will return only string values.
      
  49. Java bigdecimal toBigInteger example
    Example below demonstrates working of bigdecimal class toBigInteger  method. Method default return type is a biginteger class object value.   If the bigdecimal object value is 201.0, method will return 201 as biginteger objects cannot hold double type values. 
     
  50. Java bigdecimal subtract method example
    Example below demonstrates working of bigdecimal class subtract method. Method returns bigdecimal object values as per context settings.
     
  51. Java bigdecimal subtract
    Example below demonstrates working of bigdecimal class subtract method. Method returns bigdecimal object values. This bigdecimal class method subtracts the object value( in which the method is invoked) by the value of object specified. 
     
  52. Java bigdecimal stripTrailingZeros example
    Example below demonstrates working of bigdecimal class stripTrailingZeros method. Method returns bigdecimal object values. This bigdecimal class method generates bigdecimal values after removing the trailing zeros of  the fractional part.
     
  53. Java bigdecimal signum example
    Example below demonstrates working of bigdecimal class signum method. Method return type is int therefore method returns integers. This bigdecimal class signum method generates, sign of the bigdecimal object value.
      
  54. Java bigdecimal shortValueExact
    In this example working of  Java bigdecimal class shortValueExact method  is demonstrated.  Method return type is short therefore it will return only short values.
      
  55. Java bigdecimal shortValue example
    In this example working of  Java bigdecimal class shortValue method  is demonstrated.  Method return type is short therefore it will return only short values.
      
  56. Java bigdecimal toBigIntegerExact example
    Example below demonstrates working of bigdecimal class toBigInteger  method. Method default return type is a biginteger class object value.