0
$\begingroup$

Suppose I have a number, x, which should be doubled every second.

If one had a function which is called exactly once every second, the solution would be simple: All you would have to do was multiplying x by 2.

What, however, can you do to achieve the same results when working not in one-second but very tiny steps?

The target function should, given a small delta time value, still multiply x by 2 every second.

An example:

1. x == 3  2. Apply the function every millisecond for one second, therefore passing 1/1000 as parameter to it  3. Now x == 6 
  • How can I solve this problem?
  • 2
    The function should multiply by $2^{1/1000}$ (the 1000th root of 2).2011-07-25
  • 1
    @Florian, that's certainly the right answer from the point of view of pure mathematics, but I suspect that if you tried to implement it in floating point, it wouldn't do what you want it to do.2011-07-25
  • 2
    Perhaps this isn't quite what you want, but... have the function store an internal counter. If the counter is less than 1000, the function returns its input. If the counter equals 1000, then the function sets the counter to 0 and returns twice its input.2011-07-25

3 Answers 3