Double Data Type in Java Programming Language

Rumman Ansari   Software Engineer   2019-03-30   11913 Share
☰ Table of Contents

Table of Content:


double Data Type in Java

double data type is the most important data type in java. Double precision, as denoted by the double keyword, uses 64 bits to store a value. Double precision is actually faster than single precision on some modern processors that have been optimized for high-speed mathematical calculations. All transcendental math functions, such as sin( ), cos( ), and sqrt( ), return double values. When you need to maintain accuracy over many iterative calculations, or are manipulating large-valued numbers, double is the best choice..

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

  • This data type is generally used as the default data type for decimal values, generally the default choice

  • Double data type should never be used for precise values such as currency

  • Default value is 0.0d

  • Example:

     double d1 = 123.4 

double Variable Declaration and Variable Initialization:

Variable Declaration : To declare a variable , you must specify the data type & give the variable a unique name.

 double area ;  

Variable Initialization : To initialize a variable you must assign it a valid value.

area = 334343.14 ;

float Variable Declaration and Variable Initialization in two steps:

double area;
area = 334343.14;
double Datatype in java

Program

// A Java program to demonstrate double data type
class CharDemo {
   public static void main(String args[])
     {
           double area;
           area = 323323.14;
           System.out.println(area);
     }
  }

Output

323323.14
Press any key to continue . . .

double Variable Declaration and Variable Initialization in one line:

double  area= 334343.14 ;
double Datatype in C java

Program

// A Java program to demonstrate double data type
class CharDemo {
   public static void main(String args[])
     {
           double area = 323323.14;
           System.out.println(area);
     }
  }

Output

323323.14
Press any key to continue . . .
double Datatype in C java