Select Page

double data type in Java


The double data type is also a floating point number. It is called double because it has a double-precision decimal number.  


nanadwumor

June 01, 2023

Primitive Data types.-double data type


  • The double data type is a floating point number.
  • It is double precision data type
  • The range is 4.9406564584124654 x 10-324 to 1.7976931348623157 x 10308. The number can be positive or negative.

RECOMMENDED ARTICLES


Variables and Literals in Java

Variables and Literals in Java

Variables are used in many situations. For Instance, game applications use variables to collect your name when you sign in; to store and keep track of your number of trials, successes and failures. In Java, a variable is a container used to store...

The print and println methods in Java

The print and println methods in Java

The print() and println() methods are Java's predefined methods used to display text output on the console. These methods are part of the Java API. The print and println methods are used to print string of characters  onto the console The print...

float data type in Java

float data type in Java

It is a floating point number. It has single precision data type. It stores a floating point number of 7 digits of accuracy. The float data type is a floating point number. It has single precision data type The float type is stored in 32 bits of...


The double data type is also a floating point number. It is called double because it has a double-precision decimal number. The double data type has 15 digits of accuracy.

The double data type is stored in 64 bits of memory. 8 bits gives a byte so double has 8 bytes of memory.


Join Other Subscribers on Our YouTube Channel and Don’t Miss a thing!


double has twice as much memory as the float data type. 

double has a much larger range of possible values than the float type. 

The range is 4.9406564584124654 x 10-324 to 1.7976931348623157 x 10308. The number can be positive or negative.

Declaring an double variable

We declare double the same as any other type :

double weight;

double height;

Alternatively, you can also declare all double variables in a row. That’s,

double height, weight;

Program demonstrates double data type

Output

Program demonstrates the double data type

Writing floating point numbers in Scientific notation

A number in Scientific notation is in the form a×10^n where a>=1 and n is an integer.  

We can write floating point numbers in scientific notation. Example: 2751632 can be written as 2.751632 × 10^6. You can also write 0.00001532 as 1532×10^-5.

In Java, the letter E or e is used to represent the figures in the scientific notation. That’s, 

2.751632 × 10^6 is typed as 2.751632E6 in Java. 

1532×10^-5 is typed as 1532e-5.

Program demonstrates floating point numbers in scientific notation

Output

Program demonstrates floating piont number in scientific notation

You May Also Like…


float data type in Java

float data type in Java

It is a floating point number. It has single precision data type. It stores a floating point...



0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *