मराठी

Differentiate between the following: float and double

Advertisements

प्रश्न

Differentiate between the following:

float and double

फरक स्पष्ट करा
Advertisements

उत्तर

float

double

1. The float data type is used to store single-precision floating-point numbers in Java.

1. The double data type is used to store double-precision floating-point numbers in Java.

2. The float data type occupies 4 bytes (32 bits) of memory.

2. The double data type occupies 8 bytes (64 bits) of memory.

3. The float data type provides approximately 6–7 decimal digits of precision.

3. The double data type provides approximately 15–16 decimal digits of precision.

4. The float data type is suitable when less precision is required.

4. The double data type is suitable when greater precision is required.

5. A floating-point literal must have the suffix f or F to be treated as a float.

5. A floating-point literal is treated as a double by default in Java.

6. Example: float a = 12.5f;

6. Example: double a = 12.5;

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - EXERCISE [पृष्ठ १३२]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
पाठ 6 Variables and Expressions
EXERCISE | Q 30. (b) | पृष्ठ १३२
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×