简体   繁体   中英

Infinity in Array in java

I tired printing Array and the end I got Infinity at last few values. What does Infinity means in Java. I am coding java in android studio.

The array is as follows aList [132.74362, 142.6408, 143.6408, 131.62733, 132.62733, 127.61245, 128.61246, 124.76465, 125.76465, Infinity, Infinity, Infinity, Infinity ]

What does Infinity mean?

Did you divide by zero?

When you divide by zero ...

In case of double/float division, the output is Infinity. The basic reason behind it is that it implements the floating point arithmetic algorithm, which specifies special values like “Not a number” OR “infinity” for “divided by zero cases” as per IEEE 754 standards.

In case of integer division, it throws ArithmeticException.

This, will print "Infinity"

    double p = 1; 
    System.out.println(p/0); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM