Question: The following function is run consecutively: 

```cpp
void MyClass::handleTriggered(float dt)
{
    // dt is time interval (period) between current call to this function and previous one
}

```

`dt` is something like `0.0166026` seconds (comes from 60 frames per second). 

I intend to do something every `0.25` seconds. Currently I'm using the fact that we are at 60 fps, i.e. function call occurs 60 times each second:

```cpp
    static long int callCount = 0;
    ++callCount;
    // Since we are going with 60 fps, then 15 calls is 1/4 i.e. 0.25 seconds
    if (callCount % 15 == 0)
        // Do something every 0.25 seconds (every 15 calls)

```

Now I wonder how I can do it another way, with `float` types rather than `int`:

```cpp
    static float sumPeriod = 0.0;
    // Total time elapsed so far
    sumPeriod += dt;
    if (/* How to compose the condition? */) {
        // Every 0.25 seconds do something
    }

```

Answer: 
You have to sum up the `dt`'s and when they hit 0.25 you subtract 0.25 from the sum and do your thing.

```
static float sum = 0.0;
sum += dt;
if(sum > 0.25) {
    sum -= 0.25;
    // Do what you want to do every 0.25 secs here.
}

```
```
static float sumPeriod = 0.0;
// Total time elapsed so far
sumPeriod += dt;
if (sumPeriod > 0.25) {
    sumPeriod -= 0.25 * int(sumPeriod / 0.25);
    // Every 0.25 seconds do something
}

```