What is double in C
×


What is double in C

190

C, double serves as a data type designed to store numbers with double precision in floating-point format.

It can hold decimal numbers with higher precision compared to the float data type.

Characteristics of double:

Size: Typically, double occupies 8 bytes (64 bits) of memory.

Precision: Offers higher precision compared to float, suitable for applications requiring more accurate decimal representation.

Range: The range and precision can vary depending on the compiler and architecture, but generally, it can represent numbers from approximately

±2.3×10−308±2.3×10 −308 to ±1.7×10308±1.7×10 308

with at least 15 decimal digits of precision.

Usage:

To declare a double variable in C, you can use the double keyword:

double myDouble = 123.456;

Example:

#include<stdio.h> 

int main() {
    double distance = 12345.6789;
    
    printf("Distance: %lf\n", distance);
    
    return 0;
}

Output:

Distance: 12345.678900

The %lf format specifier is used to print double values with printf().

double is commonly used in scientific computations, financial calculations, and other applications where high precision is required for decimal values.



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments