In the previous article, I have explained about expressing the floating-point and double literals in standard and scientific formats.
In this article, I am going to explain about representing floating-point and double literals in different ways.
Java for Testers – Different ways of representing floating-point and double literals
Floating-point and double literals can be representing in the following different ways:
1) Floating-point literals can be represented by adding a small letter or capital letter at the end of the literal value as shown below
float a = 123.456f
float a = 123.456F
2) Double literals can be represented by adding a small letter or capital letter or no letter at the end of the literal value as shown below
double a = 123.456;
double a = 123.456d;
double a = 123.456D;
Below are the screenshots for the practical demonstration of the above different possibilities:
Here conclude this article on assigning the different ways of representing floating-point and double data type literals.
In the next article, I will explain different Type Conversions in Java.
- > To learn more about Java, continue to the next post (Click on Next Post link below)
- > Check complete Java Tutorial Contents here (Click here)
Please leave your questions/comments/feedback below:
Happy Learning ?
Arun Motoori (www.QAFox.com)
On a mission to help the Testing Community in all possible ways.