News for hackers. Stuff that matters.
Re:OMG: Our Machinery Guidebook by mwcremer on Wednesday December 11, 2019 @06:25PM (#21767879)
I.e., use a double parameter that specifies seconds, instead of an uint32_t that specifies milliseconds.

This can have surprising and sometimes unpleasant consequences; see https://0.30000000000000004.com

Re:OMG: Our Machinery Guidebook by United857 on Wednesday December 11, 2019 @06:35PM (#21767935)
Better yet, use std::chrono. Yes, it's C++. But this is an example of how properly applied bits from C++ can make things easier to reason about and type-safe, rather than "let's avoid C++ as much as possible".

No ambiguity for the programmer as to what the underlying units are, and no unnecessary int/float conversions. All the book-keeping and conversions are taken care of by the compiler with zero run-time size or perf overhead.

Re:OMG: Our Machinery Guidebook by flohofwoe on Thursday December 12, 2019 @06:38AM (#21771031)
std::chrono is a terribly overengineered API even for the STL, and many game companies have banned parts or all of the STL for good reasons (usually not std::chrono related though).

Using an uint64_t (instead of uint32_t or double) to carry "opaque ticks", and a handful conversion function to convert to real-world time units is fine and just a few lines of code.

Re:OMG: Our Machinery Guidebook by niklasgray on Thursday December 12, 2019 @01:03PM (#21774434)
This is exactly what we do.
Re:OMG: Our Machinery Guidebook by chrisseaton on Wednesday December 11, 2019 @08:53PM (#21768659)
What practical problems do you think this could cause in specifying or measuring time?
Re:OMG: Our Machinery Guidebook by bobdobbs666 on Thursday December 12, 2019 @06:24AM (#21770966)
The patriot missile system tended to miss due to numerical error accumulated due to using floats to count time.

http://www-users.math.umn.edu/~arnold//disasters/patriot.htm...

Re:OMG: Our Machinery Guidebook by chrisseaton on Thursday December 12, 2019 @06:44AM (#21771046)
> due to using floats

No they weren't using floats. The article you've linked to says this really clearly.

> This calculation was performed using a 24 bit fixed point register

Re:OMG: Our Machinery Guidebook by bobdobbs666 on Thursday December 12, 2019 @12:45PM (#21774218)
http://www.cs.unc.edu/~smp/COMP205/LECTURES/ERROR/lec23/node...

They meant fixed precision not fixed point math.

Re:OMG: Our Machinery Guidebook by boterock on Wednesday December 11, 2019 @09:36PM (#21768825)
it would still be an offset much less than the loss of precision by storing int milliseconds. There are also some techniques for dealing with the time inaccuracies, although I feel those aren't widely known.