Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Views  (Read 1959 times)

0 Members and 1 Guest are viewing this topic.

Powereleven

  • Newbie
  • *
  • Posts: 36
    • View Profile
Views
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Views
« Reply #1 on: January 27, 2018, 08:21:46 am »
Do you mean the tutorial?

It's a typo, obviously.
Laurent Gomila - SFML developer

Powereleven

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Views
« Reply #2 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?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Views
« Reply #3 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything