0

{C language} why those are not same?

#include <stdio.h> int main() { float a=10.5; printf("%d",sizeof (a)) ; printf("\n"); printf("%d",sizeof 10.5) ; return 0; }

23rd Nov 2020, 1:56 PM
saso yoo
saso yoo - avatar
6 Respostas
+ 2
In C , a floating number is double unless you specify it. Try sizeof 10.5f
23rd Nov 2020, 2:07 PM
Hima
Hima - avatar
+ 1
Thanks for the answer
23rd Nov 2020, 2:17 PM
saso yoo
saso yoo - avatar
+ 1
Hima Nothing wrong.. i mean floating number means float type number we think in c. So better to call decimal number or floating point number.. (I mean there confusing).. float type have always 4 bytes.. Decimal numbers have fraction part, no limitation (single precision, double precitions)
23rd Nov 2020, 2:48 PM
Jayakrishna 🇮🇳
+ 1
In C language, floating-point constant is double precision floating-point type by default.
25th Nov 2020, 7:03 AM
gohst
0
@Hima "a floating number is double" is confusing.... It may be better to say "Defaultly a decimal value is double type in c" So 10.5 double value 10.5f is float type, also a is float type..
23rd Nov 2020, 2:37 PM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 what's wrong with floating number ? And why it's conflicting ? "floating point numbers are numbers that contain floating decimal points."
23rd Nov 2020, 2:42 PM
Hima
Hima - avatar