Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.
Need Java help!?
I have a question about primitive variable types. How come whenever I declare a long variable, I have to put an "l" at the end of the value or else I get a compiler error saying "integer number too large."? It also happens with doubles, too.
And I have another question about "double" variable types. How come the Java documentation thing lists them as being able to hold values from "8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative)." But when I put in a higher value, even something (relatively) small like two billion won't fit unless I put a "d" at the end of the value. Why is this? And what does the "-324d" and "+308d" thing mean? Is this scientific notation or is that the decimal precision of the "double" variable type? Thanks.
1 Antwort
- vor 1 JahrzehntBeste Antwort
for normal int initialization like
int a = 9 (9 would be treated as int type)
int a = 9L (9 would be treated as long type)
the truth applies to the relation between floating point and double.
int -> 32 bits;
long -> 64 bits;
float -> 32 bits;
double ->64 bits;
for all of the primitive data types, length to store the value is calculated during compile time.
Thats why java need to know whether it is a int or long; float or double.
For Object data type, during the compile time, a length of space used is calculated for the reference only, not the actual value.
4.0454545e-324d means 4.0454545 * (10)^-324
10^2 means 10 power 2
4.05e-2d means 0.0405
The d denotes that the whole value 4.4343..... is a double, not refers to 324 only.
:) good question !