Linked Questions
34 questions linked to/from When does appending an 'f' change the value of a floating constant when assigned to a `float`?
107 votes
10 answers
81k views
"f" after number
What does the f after the numbers indicate? Is this from C or Objective-C? Is there any difference in not adding this to a constant number? CGRect frame = CGRectMake(0.0f, 0.0f, 320.0f, 50.0f); Can ...
102 votes
9 answers
130k views
why f is placed after float values?
I don't know why f or F is placed after float values in Java or other languages? for instance, float fVariable = 12.3f; any features other than indicating that this is a float value?
86 votes
9 answers
10k views
Is 'float a = 3.0;' a correct statement?
If I have the following declaration: float a = 3.0 ; is that an error? I read in a book that 3.0 is a double value and that I have to specify it as float a = 3.0f. Is it so?
87 votes
7 answers
89k views
What's the use of suffix `f` on float value
I am wondering what the difference is between these two variables in C: float price = 3.00; and float price = 3.00f; What is the use of suffix f in this case?
4 votes
6 answers
3k views
Is there a functional difference between "2.00" and "2.00f"?
I ask because I am using the Box2D library, which calls for mostly float arguments. Although I see a lot of example code that uses the 0.00f format, I am not quite sure if there is an actual ...
6 votes
5 answers
687 views
Is the letter "f" necessary if the decimal point is written? [duplicate]
What is the difference between the 2 following code lines? #define F_SAMP 10000.0f #define F_SAMP 10000.0 Aren't both float? (By the way, in this particular case compiler is XC16 but I do not think ...
5 votes
3 answers
875 views
Is literal double to float conversion equal to float literal?
Can there be a difference in bit-representation between a direct assignment of a floating point literal float x = 3.2f; and a double implicitly converted to a float float x2 = 3.2;? I.e. is #define ...
4 votes
4 answers
605 views
Why do we need std::numeric_limits::max_digits10?
I understand that the floating points are represented in memory using sign, exponent and mantissa form which have limited number of bits to represent each part and hence this leads to rounding errors. ...
-2 votes
3 answers
4k views
How to define a double constant in C?
How to define a double constant in C ? For float is like so: #define powerFactor 1.00f For double i dont know: #define energy 55639.00xx Should xx be d, ld, lf, nothing or compiler specific?
2 votes
2 answers
2k views
Why Do I get the error "integer literal is too large to be represented in any integer type" when assigning the maximum single point float value?
I know that according to the single point standard IEEE the maximum value of a float is 1.11111111111111111111111 *2^127 which converted in decimal is exactly this huge number -> ...
10 votes
2 answers
350 views
Why does gcc compare seemingly equal floating point values as different with "-fexcess-precision=standard"?
Look at this snippet: int main() { double v = 1.1; return v == 1.1; } On 32-bit compilations, this program returns 0, if -fexcess-precision=standard is specified. Without it, the program ...
4 votes
2 answers
628 views
Is Using double variable type instead of float a bad habit [closed]
I have to code C for my college exams and I have practice of declaring double variables instead of float variables. Is it a bad habit? Can they deduct marks for it? (we never exceed the float limit) I ...
2 votes
2 answers
165 views
Meaning of "A C compiler by default saves a floating point constant as double"
I was just beginning out with C (K.N king's C Programming) when I came across the following passage: By default, floating constants are stored as double-precision numbers. In other words, when a C ...
-1 votes
2 answers
581 views
Why when using printf float and double show the same number of digits?
I wanted to see the difference in how many digits i get when using float and when using double but i get the same results #include <stdio.h> int main() { float x=1.2222222222222222f; ...
2 votes
2 answers
452 views
C# explanation of the "f" keyword for a float vs implicit and explicit conversions [duplicate]
So I don't really get the conversion from a float to a double e.g: float wow = 1.123562641346; float wow = 1.123562641346f; The first one is a double that gets saved in a variable that has memory ...