What's new

Closed Question about double and float data type in java

Status
Not open for further replies.

NightJames

Addict
Joined
Jan 11, 2015
Posts
104
Reaction
13
Points
123
Age
23
Paano malalaman kung float o double yung decimal.
Example: 0.1 - double or float?
Tanong samin ng teacher namin.
 
Ito ts baka makatulong to at baka masagutan din yang tanong mo.. ☺
Untitled2.png
Pwede ding masabi na, kapag yung sa declaration ay ganito..
double a = 0.1; //Matik na to na double siya kase yun yung datatype
float b = 0.1; //Matik na din to na float kase sa datatype niya din sa declaration
 

Attachments

Last edited:
float - 32-bit, can have up to 7 decimal digits
double - 64-bit, precision can go up to 15 decimal digits

float floatMo = 1.005f;
be conscious about the "f"

float a = 1.00000111111111f;
double d = 1.000000111111111111111111;
System.out.println(a);
System.out.println(d);


output:
1.0000011
1.0000001111111112
 
Status
Not open for further replies.
Back
Top