Delta Time - Streamlined Time Keeping For Games

jordan4ibanez jordan4ibanez002 at gmail.com
Sat Aug 20 22:29:13 UTC 2022


On Saturday, 20 August 2022 at 11:26:08 UTC, Abdulhaq wrote:
> On Saturday, 20 August 2022 at 00:32:25 UTC, jordan4ibanez 
> wrote:
>
>> This library allows you to track it precisely between frames. 
>> Nanoseconds precise.
>>
>
> just out of curiosity, when you say nanoseconds precise do you 
> mean to imply it is nanoseconds accurate? And if so, what makes 
> you confident that that is the case?

So basically, what I am saying is, you WILL get the same double 
floating point number no matter what way you try to do this if 
the situation on the player's computers are identical. And yes I 
am saying it is nanoseconds accurate, the base implementation is 
for the duration. When it is given into a usable value. Well, I 
think you know what the following will print :P

```d
import std.stdio;
double a = 0;
// Do some math with a
double b = 0;
// Do some other math with b that should yield the EXACT value of 
a
writeln("Does a == b? ", a == b);
```

You could (technically) use the delta time to keep the total time 
that the program has been running. But the time skew due to 
double floating point precision might end up leaving your program 
thinking it's been on for a few days if you left it on for a week 
or two. I'm kidding, but you will end up with a time skew of 
perhaps a few seconds or minutes depending on how badly your cpu 
calculates MonoTime Duration, along with how many errors the 
double floating point calculation encounters.

So basically what I'm saying is: It is absolutely accurate down 
to the nanosecond, in code, in the base calculation of Duration. 
But the conversion from this calculation to usable double 
floating point values in production for player experience will 
always be inaccurate. This is why you do not do any financial 
calculations in float or double haha. I hope this clarified 
everything. Thank you for reading.


More information about the Digitalmars-d mailing list