Constructor descriptionbigdecimal (int) Creates an object with the integer value specified by the parameter. bigdecimal (double) creates an object with the double value specified by the parameter. bigdecimal (long) creates an object with a long integer value specified by the parameter. bigdecimal (String) creates an object with a numeric value specified by the argument as a string.
BigDecimal (int) Creates an object with the integer value specified by the parameter.
BigDecimal (double) creates an object with the double value specified by the parameter.
BigDecimal (long) creates an object with a long integer value specified by the parameter.
bigdecimal (String) creates an object that has a numeric value specified by the argument as a string
Method description Add (BigDecimal) BigDecimal the value in the object, and then returns the object. Subtract (BigDecimal) subtracts the value from the BigDecimal object and returns the object. Multiply (BigDecimal) multiplies the values in the BigDecimal object and returns the object. Divide (BigDecimal) divides the values in the BigDecimal object, and then returns the object. ToString () willConverts the numeric value of the BigDecimal object into a string. Doublevalue () willThe values in the BigDecimal object are returned as double-precision numbers. bigdecimal object is returned as a single precision number. bigdecimal object is returned as a long integer. bigdecimal object is returned as an integer.
Add (BigDecimal) BigDecimal the value in the object, and then returns the object.
Subtract (BigDecimal) subtracts the value from the BigDecimal object and returns the object.
Multiply (BigDecimal) multiplies the values in the BigDecimal object and returns the object.
Divide (BigDecimal) divides the values in the BigDecimal object, and then returns the object.
ToString () willConverts the numeric value of the BigDecimal object into a string.
Doublevalue () willThe values in the BigDecimal object are returned as double-precision numbers.
Floatvalue () willThe value in the BigDecimal object is returned as a single precision number.
Longvalue () willThe value in the BigDecimal object is returned as a long integer.
intvalue () will bigdecimal object is returned as an integer.
note that because of general numeric types, such as double , can not accurately represent 16 digits above the number, when using bigdecimal, Application bigdecimal (String) It makes sense for the constructor to create objects. In addition, bigdecimal is creating objects, we can't use traditional +, -, *, /and other arithmetic operations characters directly perform mathematical operations on their objects, and must call their corresponding methods. The parameters in the method must also be
About arithmetic for bigdecimal data types in Java