OverFlow and UnderFlow

suggest change

Float data type

The float data type is a single-precision 32-bit IEEE 754 floating point.

Float overflow

The largest finite value is about 3.4028235e+38. When a result exceeds that value, it becomes Infinity.

float f = 3.4e38f;
float result = f*2;        
System.out.println(result); //Infinity

Float UnderFlow

The smallest positive finite value is about 1.4e-45f. When a result goes below that value, it becomes 0.0. The literal 1e-45f is already rounded to that smallest value; dividing it by 1000 underflows.

float f = 1e-45f;
float result = f/1000;
System.out.println(result);

double data type

The double data type is a double-precision 64-bit IEEE 754 floating point.

Double OverFlow

The largest finite value is about 1.7976931348623157e+308. When a result exceeds that value, it becomes Infinity.

double d = 1e308;
double result=d*2;      
System.out.println(result); //Infinity

Double UnderFlow

The smallest positive finite value is about 4.9e-324. When a result goes below that value, it becomes 0.0.

double d = 4.8e-323;
double result = d/1000;
System.out.println(result); //0.0

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents