-2

So i'm trying to read some c code.

They write out float x =2.0f

I'm trying to figure out what the 2.0f stands for because f isnt a variable defined before.

Help?

  • 4
    Does this answer your question? [What's the use of suffix \`f\` on float value](https://stackoverflow.com/questions/5026570/whats-the-use-of-suffix-f-on-float-value) – sj95126 Oct 23 '21 at 19:04

1 Answers1

0

f means "float literal value".

DanFQ
  • 44
  • 4
  • It is not a "literal value" as nothing like this does not exist in the C language – 0___________ Oct 23 '21 at 19:13
  • 1
    @0___________: It is a literal value. In this context, “literal” means the value of a thing is expressed in its name (that is, the source text that specifies it). For example, a variable `x` is not a literal because we do not know what its value is. But a constant like `3` or `4.5` is a literal because its value is known from its source text. – Eric Postpischil Oct 23 '21 at 19:29
  • @EricPostpischil it is float constant not literal – 0___________ Oct 23 '21 at 19:32
  • @0___________: Yes, the C standard specifies it as a “floating constant.” That does not mean that is the only phrase that can describe it. [“Literal” is a common term in computer science](https://en.wikipedia.org/wiki/Literal_(computer_programming)) used to mean “representing a fixed value in source code.” – Eric Postpischil Oct 23 '21 at 20:17