Showing posts with label add two double values. Show all posts
Showing posts with label add two double values. Show all posts

Monday, September 21, 2015

How To Use Variables In Java Programs Post 6

Hi All...!

This post is about how to use "double" data type in Java programming. "double" is a data type in Java which can hold decimal values up to 64-bits. To learn more about Java data type please read Data Types In Java.

Let's see how to use "double" data type in Java code.



Note:

We have assigned 1 for double d but there is 1.0 in the out put this happens because double data type dedicated for decimal values.

Let's assign 1.0 to double d and check error occurs with float data type is arise again ? Error occurs in float data type please read How To Use Variables In Java Programs Post 5




It doesn't happen because compiler by default take decimal values as double value.

Let's add two double values,





Another way to do double value addition,