Hi,
All the three possible cases of errors in floating point arithmetic are shown below:
public class ErrorDoubleCalc
{
public static void main(
String args[])
{
System.out.println( " Dividing 2.0 by 0.0 : " + 2.0/0.0 );
System.out.println( " Dividing -2.0 by 0.0 : " + -2.0/0.0 );
System.out.println( " Dividing 0.0 by 0.0 : " + 0.0/0.0 );
}
}
This is the output :
Dividing 2.0 by 0.0 : Infinity
Dividing -2.0 by 0.0 : -Infinity
Dividing 0.0 by 0.0 : NaN