SFML community forums
Help => Graphics => Topic started by: Powereleven on January 27, 2018, 03:26:47 am
-
Quick question: on the view topic there is this line:
view.setViewport(sf::FloatRect(0.25f, 0.25, 0.5f, 0.5f));
why didn't the writer use the sufix f in the second parameter and used in the other 3?
-
Do you mean the tutorial?
It's a typo, obviously.
-
I know that without the sufix f the float is converted to a double. But is there a good reason to add the f sufix besides insignificant performance improvement? Also, why does C++ converts automatically floats to doubles if you don't add the f sufix, but does not convert int to floats, for example?
-
It's not converted to a double. 0.25 is a double. 0.25f is a float. The double (0.25) is converted to a float when passed as that parameter.
The reason to add it is to be clear as to the intention of the value.