Floating-Point Variable Types, its size, range of value - C Data Type

C examples for Data Type:float

Introduction

Floating-point variable types only store floating-point numbers.

Keyword Number of bytes Range of values
float 4 +/-3.4E+/-38 (6 to 7 decimal digits precision)
double 8 +/-1.7E+/-308 (15 decimal digits precision)
long double 12 +/-1.19E+/-4932 (18 decimal digits precision)

Demo Code

#include <stdio.h> 
  
int main(void) 
{ 
    float radius;
    double biggest;
    /*from w  ww  . j a  v a  2  s .  c om*/
    printf("%f",radius);
    
    return 0;
}

To write a constant of type float, append an f to the number.

Demo Code

#include <stdio.h> 
  
int main(void) 
{ 
    float radius = 2.5f;
    // ww  w . j a v  a 2s.c  om
    double biggest = 123E30;
    
    printf("%f",radius);
    
    return 0;
}

Result

To specify a long double constant, you append an uppercase or lowercase letter L

Demo Code

#include <stdio.h> 
  
int main(void) 
{ 
    long double huge = 1234567.89123L;
    /*from   w  w  w. j  a  v a 2 s . c  o  m*/
    printf("%f",huge);
    
    return 0;
}

Result


Related Tutorials