- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Float and Double in C
Float
Float is a datatype which is used to represent the floating point numbers. It is a 32-bit IEEE 754 single precision floating point number ( 1-bit for the sign, 8-bit for exponent, 23*-bit for the value. It has 6 decimal digits of precision.
Here is the syntax of float in C language,
float variable_name;
Here is an example of float in C language,
Example
#include<stdio.h> #include<string.h> int main() { float x = 10.327; int y = 28; printf("The float value : %f
", x); printf("The sum of float and int variable : %f
", (x+y)); return 0; }
Output
The float value : 10.327000 The sum of float and int variable : 38.327000
Double
Double is also a datatype which is used to represent the floating point numbers. It is a 64-bit IEEE 754 double precision floating point number for the value. It has 15 decimal digits of precision.
Here is the syntax of double in C language,
double variable_name;
Here is an example of double in C language,
Example
#include<stdio.h> #include<string.h> int main() { float x = 10.327; double y = 4244.546; int z = 28; printf("The float value : %f
", x); printf("The double value : %f
", y); printf("The sum of float,double and int variable : %f
", (x+y+z)); return 0; }
Output
The float value : 10.327000 The double value : 4244.546000 The sum of float, double and int variable : 4282.873000
- Related Articles
- Difference between float and double in C/C++
- How to compare float and double in C++?
- Comparison of double and float primitive types in C#
- Difference Between Float and Double
- Round float and double numbers in Java
- Difference between float and double in Arduino
- What is the most effective way for float and double comparison in C/C++?
- Comparison of double and float primitive types in Java
- What is the difference between a float, double and a decimal in C#?
- Checking if a double (or float) is NaN in C++
- Modulus of two float or double numbers using C
- C++ Program to find size of int, float, double and char in Your System
- Get the absolute value of float, int, double and long in Java
- When can a double-type be preferred over float-type in Java?
- Assigning an integer to float and comparison in C/C++

Advertisements