SFML community forums

Help => Graphics => Topic started by: Powereleven on January 27, 2018, 03:26:47 am

Title: Views
Post 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?
Title: Re: Views
Post by: Laurent on January 27, 2018, 08:21:46 am
Do you mean the tutorial?

It's a typo, obviously.
Title: Re: Views
Post by: Powereleven on January 27, 2018, 09:06:49 pm
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?
Title: Re: Views
Post by: Hapax on January 27, 2018, 10:08:20 pm
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.