+ 2
Why is constant 0.7 bigger than float 0.7 in C ?
5 Respuestas
+ 9
You shouldn’t test for exact equality of floating point values. Also 0.7 is treated as a double, which uses more bits for precision. In your code you are comparing two different types.
+ 8
Yes it will print hii because
float a = 0.7;
The value of a is float type but the type of 0.7 is double and double size precision more than float values .
By default decimal values are float types if u want to make it float type then u have to write float a=0.7f dont .
Hope you understood
+ 3
no. you will have to handle that conversion yourself. if you need, you can write a float by adding “f” to the end of a number: ‘12.6f’ would be a floating point.
+ 1
Brian R That is to say C won't change num's type when comparing, right?
0
Brian R Thanks. So C won't do conversion and allows comparing between different type. I think it shouldn't happen. In my opinion, it may cause many bug.