Java Basic---> Digital processing and operations---->java API

Source: Internet
Author: User
Tags mathematical constants

*javathe numeric processing class in

1. Overview: There are many ready-made APIsinJava that can be used for numerical processing (mathematical operations) , and programmers will be able to write programs directly using these APIs . The numeric processing classes in Java include:

A) Java.text.NumberFormat class (abstract Class)

  • Java.text.
  • Java.text.DecimalFormat class: For formatting numbers
      • Numeric values can be formatted as integers, floating-point numbers, scientific notation, percentages, etc.
      • Can control the accuracy of numbers
      • You can add units to numbers
    • You need to use a formatted string to indicate the format that you want the value to be rendered in, and theDecimalFormat class defines some special characters, representing different formats, identifying the formatting meanings of the special characters to know how to define the numeric format .
    • Use Java.text.DecimalFormat A member method in a class to format a number to display and store
      • Program: Eclipse in javatest in Engineering Package Operator_and_math in the Javaapi_decimalformat.java

b) Random class: For random number processing

    1. The random () function in the Math class can be used to generate
    2. each function in the random class can also be used for random number processing:

c) Math class: For numerical calculations

    1. This class contains commonly used mathematical operations, such as trigonometric functions, the reciprocal conversion of angles and radians, exponential functions, rounding functions, maximum, minimum, average, and random number generation methods.
    2. This class also includes some common mathematical constants, such as PI,E , etc.
    3. these constants and functions in the math class are static and can be used directly with math. function name and Math. The constant name to invoke.

d) BigInteger class:

    1. Overview: When you need to process a value that is larger than the maximum value that the int variable can handle 2^31-1 , you need to use BigInteger class to handle numbers of these large values.

E) BigDecimal class:

    1. Overview: TheBigInteger class handles only integers, while the BigDecimal class can handle large values of any precision

Java Basic---> Digital processing and operations---->java API

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.