English

Explain the Floating Point data tyре.

Advertisements

Question

Explain the Floating Point data tyре.

Explain
Advertisements

Solution

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.

  1. float: It occupies 4 bytes (32 bits) of memory and stores decimal numbers with single precision (approximately 6–7 decimal digits).
  2. 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
  Is there an error in this question or solution?
Chapter 6: Variables and Expressions - EXERCISE [Page 131]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 6 Variables and Expressions
EXERCISE | Q 5. | Page 131
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×