
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Underflow of Datatypes in Java
Underflow occurs when the given value is less than the maximum prescribed size of a data type. The underflow condition can result to an error or now the implementation of the programming language handles it on its own.
To display underflow of datatypes, I have taken an example of double datatype. Double data type is a single-precision 64-bit IEEE 754 floating point.
The following program display underflow of datatype in Java.
Example
public class Demo { public static void main(String[] args) { System.out.println("Displaying Underflow... "); double val1 = 3.2187E-320; System.out.println(val1/1000000); } }
Output
Displaying Underflow... 0.0
In the above program, the double variable is initialized to.
double val1 = 3.2187E-320;
After that, division operation is performed on it to check for underflow.
val1/1000000
It returns the following.
0.0
Advertisements