Showing posts with label numeric. Show all posts
Showing posts with label numeric. Show all posts

Sunday, June 3, 2012

the double data type

A double is a numeric data type. Suitable for storing floating point (decimal) numbers such as weight, length, etc. Any kind of number with a "point something' in it such as 7.6, 10.5, 1.2, etc.

Where a double has not been assigned a value, by default it's value is 0.0d.

The format for declaring a double variable is:

   Type identifier;

Where the Type is double and the identifier is weight:

   double weight;

...and where a value of 100.50 has been assigned:

   double weight = 100.50;


You can declare a double in one statement and assign it a value in another statement:

   double weight;
   // other statements...
   weight = 100.50;



See also:

"Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)" ( http://bit.ly/xesQuj )
"Java For Complete Beginners - Double variables" ( http://bit.ly/ZzYTJ9 )