Double is more precise than float. The 4 bytes saved on a float are usually not very relevant. However, if you need to save large amounts of numbers (e.g. in an array), and you don't need the extra precision, you might save some memory by using float.
Chat with our AI personalities
In Java, you can use either a float or a double
THIS IS FOR JAVA i don't know about anything about other languages yes it can be assignedthe syntax is:int (number) = (float) numberFOR EXAMPLE:int = a;a = (float ) 5.5;if the (float) is not there then in Java it gives an error saying precision loss of data type
The non-class Java data types are primitives: * byte * short * int * long * float * double * boolean * char
it is the same as an int, String, or any of the others:float myVar = 5.7f;If you try to assign a decimal number you must place an "f" at the end, otherwise Java will assume you are trying to assign a double.
In C float a[8]; In Java float a[] = new float[8];