The simple floating-point number types in Java float and double are not capable of operation. It's not just Java, it's also a problem in many other programming languages.What will we see if we compile and run the following program?public class Test {
What are the 8 rounding modes for BigDecimal in Java? The following Changsha Obertek Software Institute and everyone together to learn it:Java.math.BigDecimalImmutable, arbitrary-precision, signed decimal number. The BigDecimal consists of an
1.BigDecimal Introduction
The BigDecimal consists of an arbitrary precision integer Non scale value and a 32-bit integer scale (scale). If it is zero or positive, the scale is the number of digits after the decimal point. If it is a negative number,
The Java.math.BigDecimal class provides arithmetic, scale operations, rounding, comparison, hashing algorithms, and format conversion operations.The ToString () method provides a canonical representation of the BigDecimal. It gives the user full
When processing some data, we hope to use the "Rounding" method, but C # uses the "four homes, six homes, five into two" method, as shown in the following example, the result is obtained using "four homes, six homes, and five into two:
double
When processing some data, we hope to use the "Rounding" method, but C # uses the "four homes, six homes, five into two" method, as shown in the following example, the result is obtained using "four homes, six homes, and five into two:
Code
When processing some data, we hope to use the "Rounding" method, but C # uses the "four homes, six homes, five into two" method, as shown in the following example, the result is obtained using "four homes, six homes, and five into two:
double d1 =
1.parseInt: Take only integer digitsFor example:parseint (3.7) Rounding result is: 3parseint (-1.1) Rounding result is:-12.math.floor: Go down to the whole, take a large integerFor example:Math.floor (3.7) Rounding result is: 4Math.floor (-1.1)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.