Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to use "floating point" in java
How to use "floating point" in java
Floating-point type sometimes has insufficient integer data, and some values used in mathematics and physics are usually expressed in decimals. Like C++, Java supports two decimal types: float and double. Table 2.2 gives their storage requirements and effective range. Table 2.2

Floating-point types and their storage requirements

shop

square

The minimum and maximum values of the 64-bit of the formula double64 are about 4.9e~324, about1.79e+308 float, and the 32-bit is about 1.4e~45, about 3.4e+38. Instead of discussing how to get these values in theory, let's look at some intuitive examples. Here are some simple examples of declaring floating-point variables: double

circumference ratio

=

3. 14 1592653589793d; flotage

speed

=

30.65f twice

gravity

=

9.8 1; Note that in order for a value to be truly considered as a floating-point number, it must end with an f (or f) suffix; Otherwise, it will be considered as a double-precision value. For double values, the d (or d) suffix is optional. So far, it has not been decided which type is usually used to store floating-point numbers. Compared with floating-point numbers, double-precision numbers actually give us twice the accuracy, but this comes at a price-usually memory consumption. Java language (a computer language, especially for creating websites)

Most methods in the API use double type when returning types and data members.