Explain the Floating Point data tyре.
Advertisements
प्रश्न
Explain the Floating Point data tyре.
स्पष्ट करा
Advertisements
उत्तर
The Floating Point Data Type in Java is a primitive data type used to store numerical values containing decimal points. It is mainly used for calculations involving fractional numbers.
- float: It occupies 4 bytes (32 bits) of memory and stores decimal numbers with single precision (approximately 6–7 decimal digits).
- double: It occupies 8 bytes (64 bits) of memory and stores decimal numbers with double precision (approximately 15–16 decimal digits).
Example:
float price = 25.5f;
double salary = 45000.75;
Here, float and double are used to store decimal values with different levels of precision.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
