What's the Difference Between "5.0F" and "5. F" in C++?


I've seen both of them being used, but I never realized the difference between them. What's the difference ?

1

4 Answers

None. 5.f is just a shorter form of 5.0f (or 5.0000f, ...).

There isn't any. They are equivalent.

There are lots of other ways to express the same float literal in C++ (5.00f, 5e0f, 5.e+0f etc).

There is no difference 5.f=5.0f=5.00f=5.000f=5.0000f etc

They are prety much the same. It will just help you in code readability.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest