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

Author Topic: float operator/ (const Time &left, const Time &right  (Read 2455 times)

0 Members and 1 Guest are viewing this topic.

nietaki

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • http://almost-done.net
float operator/ (const Time &left, const Time &right
« on: February 28, 2012, 08:14:20 pm »
Just a brief feature request: I love the Time functionality so far, but I realized I could find such an operator quite useful:
Code: [Select]
float operator/ (const Time &left, const Time &right)
//or, for my particular use, even better
int operator/ (const Time &left, const Time &right)

This way I could, for example, do

Code: [Select]
int frames_to_advance = diffTime / frameTime

without resorting to AsMilliseconds() or perhaps multiple substraction. Plus It might be faster if it was implemented inside the class instead of by the users.

Does this make any sense to anyone?

Tex Killer

  • Full Member
  • ***
  • Posts: 242
    • View Profile
float operator/ (const Time &left, const Time &right
« Reply #1 on: February 28, 2012, 08:23:40 pm »
Why would this operator work with milliseconds? The time can be extracted as seconds, milliseconds or microseconds on the new API. If you want to do calculations using the milliseconds representation, convert the time to milliseconds before doing it.

nietaki

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • http://almost-done.net
float operator/ (const Time &left, const Time &right
« Reply #2 on: February 28, 2012, 08:49:35 pm »
I don't think you understood me correctly. I would like to do calculations on the Time class (divide one time period by another), but now to do it I have to convert to milliseconds.

Tex Killer

  • Full Member
  • ***
  • Posts: 242
    • View Profile
float operator/ (const Time &left, const Time &right
« Reply #3 on: February 28, 2012, 09:46:31 pm »
Ok, now I get it... The time representation doesn't matter, since you just want the ratio between two time objects.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
float operator/ (const Time &left, const Time &right
« Reply #4 on: February 29, 2012, 08:08:00 am »
Laurent Gomila - SFML developer

 

anything