+ 1

What is a double?

1st Aug 2016, 8:03 PM
Julian Rivera
Julian Rivera - avatar
4 Answers
+ 6
A double is an IEEE754 double-precision floating point number, similar to a float but with a larger range and precision. IEEE754 single precision numbers have 32 bits (1 sign, 8 exponent and 23 mantissa bits) while double precision numbers have 64 bits (1 sign, 11 exponent and 52 mantissa bits). Java's Primitive Data Types boolean: 1-bit. May take on the values true and false only. byte: 1 signed byte (two's complement). Covers values from -128 to 127. short: 2 bytes, signed (two's complement), -32,768 to 32,767 int: 4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647. long: 8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807. float: 4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative). double: 8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative). char: 2 bytes, unsigned, Unicode, 0 to 65,535
2nd Aug 2016, 10:56 AM
WPimpong
WPimpong - avatar
+ 2
You will see most of the time we use double rather than float in Java . one reason is while initializing float number you have to write 'f' followed by number. float num = 3.12f; while in double, double num = 3.12;
6th Aug 2016, 10:33 AM
Suyash Kathar
Suyash Kathar - avatar
0
For numbers with decimal points
3rd Aug 2016, 3:07 AM
Evgeni Kuzmov
Evgeni Kuzmov - avatar
0
sneaky
5th Aug 2016, 12:35 PM
Tammie Younger
Tammie Younger - avatar