0

Hii guys what is the difference between float and double in c

29th Apr 2022, 3:05 PM
saseentharan p
saseentharan p - avatar
6 Antworten
+ 2
float - single precision floating-point type. Matches IEEE-754 binary32 format if supported. double - double precision floating-point type. Matches IEEE-754 binary64 format if supported Source : https://en.cppreference.com/w/cpp/language/types
29th Apr 2022, 3:20 PM
Arsenic
Arsenic - avatar
+ 2
saseentharan p technical standards for floating point arithmetic https://en.wikipedia.org/wiki/IEEE_754
29th Apr 2022, 3:22 PM
Arsenic
Arsenic - avatar
+ 2
saseentharan p , If You want use any decimal point number like 4.56, -66.7 etc, You can use "float" or "double" in declaration and initialisation of variable which is identically Same, But having some difference. But Remember this point :- 1. In Float, The Number has precision upto 6 digits. It means that Any number has 6 digits after decimal point. For e.g. 4.56 is store or print as 4.560000 . If variable declared with "float" as data type, it consumes 4 Bytes (32 Bits) memory. 2. In Double, The Number has precision upto 10 to 12 digits. If variable declared with "double" as data type, it consumes 8 Bytes (64 Bits) memory. Double is higher precision than Float in C language. If You use or store Fractional Number (E.g. 3.45, -0.12 etc) without any restrictions of accuracy, Then You can use "float" as data type. But If you want to Store or Output an Accurate Fractional Number i.e You want More Accuracy, Then You should use "double" as data type .
29th Apr 2022, 5:50 PM
Rudra
Rudra - avatar
+ 1
google is your friend https://www.codingninjas.com/blog/2021/05/28/difference-between-float-and-double-in-c-c/?amp=1/ the important part: " Double is more precise than float and can store 64 bits; double the number of bits float can store. We prefer double over float if we need to do precision up to 15 or 16 decimal points; otherwise, we can stick to float in most applications, as double is more expensive. "
29th Apr 2022, 3:18 PM
Bob_Li
Bob_Li - avatar
+ 1
Thanks for the information
29th Apr 2022, 3:24 PM
saseentharan p
saseentharan p - avatar
0
What is meant by IEEE--754
29th Apr 2022, 3:21 PM
saseentharan p
saseentharan p - avatar