3 Special columns for Java floating-point operations

Source: Internet
Author: User

There are 3 special columns in the Java floating-point data, positive infinity, negative infinity, and non-number.

The positive number is divided by the floating point 0 to get the positive infinity;

Negative infinity is obtained by dividing the number by the floating-point number 0;

Floating-point number 0 divided by floating-point 0 to get non-numbers (NaN);

public class Floattest {
public static void Main (string[] args) {
Float af = 8.15464156f;
The value of AF will change
SYSTEM.OUT.PRINTLN (AF);
Double A = 0.0;
Double C = double.negative_infinity;
float d = float.negative_infinity;
The negative infinity of float and double is equal
System.out.println (c = = d);
0.0/0.0 will appear non-number
System.out.println (a/a);
Two non-numbers are not equal
System.out.println (a/a = = Float.nan);
All positive infinity are mostly equal.
System.out.println ((1.0/0) = = (2.0/0));
Negative number divided by 0.0 to get negative infinity
System.out.println ( -1/a);
Integers divided by 0 will throw an exception
System.out.println (0/0);
}

}

Related Article

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.