The Double class wraps a value of the primitive type double in an object. An object of type Double contains a single field whose type is double.
Holds signed IEEE 64-bit (8-byte) double-precision floating-point numbers that range in value from -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values and from 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values. Double-precision numbers store an approximation of a real number.
The Double data type provides the largest and smallest possible magnitudes for a number.
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
1. In the MainActivity.java file, add the below to the onCreate method. This will create a Double variable named myDouble.
double myDouble;
2. Compile and run!
Resources:
http://developer.android.com/reference/java/lang/Double.html
http://www.tutorialspoint.com/java/java_basic_datatypes.htm
http://msdn.microsoft.com/en-us/library/x99xtshc.aspx
Showing posts with label Data Types. Show all posts
Showing posts with label Data Types. Show all posts
Create an Integer Variable
How to Create an Integer Variable
This will declare an integer variable
Integer was added in API Level 1
An integer is a number from -2147483648 to 2147483647. The integer data type is a 32-bit signed two's complement integer. Integer is generally used as the default data type for integral values unless there is a concern about memory. The default value is 0.
1. Create an Android project, if you don't already have one.
2.In the MainActivity.java file, add the code below to the onCreate method. This will create an integer variable named myInteger.
int myInteger;
3. Compile and run!
Related Articles:
Subscribe to:
Posts (Atom)
Popular Posts
- android:ellipsize - Add an ellipsis(...) in a TextView
- Save LogCat to a Text File
- Solution: error: Error parsing XML: unbound prefix
- Perform an Action after Enter keypress on EditText
- Intent setType(String type) - How to Set an Explicit MIME data type
- Cursor getColumnIndex - Get the Index for a Column Name
- android:nextFocusRight - Set the Next Focus Right to a TextView/EditText
- android:textColorHint - Set the Color of Hint Text in TextView/EditText
- android:nextFocusDown - Set Next Focus to a TextView/EditText
- Determine the Hex value for a color