Does mod() work? Or am I high?

If the software engineer is implementing it in pure C, how would they solve that problem? As far as I’m aware, round or any equivalents in C also don’t hide floating point inaccuracies and as such they regularly have to compare to some epsilon or use the method proposed above with the addition. It’s a basic standard for comparing floating point numbers and is being taught by default, as far as I’m aware (at least the CS courses I took always made sure we used that method and were aware of it).

Yeah, that’s my problem here as well. Using Rational is a brilliant solution and I would be on it like a shot, except that the embedded software engineers aren’t going to implement their own base type in C just for this.

I was under the impression we are talking about Julia.

As I stated a few posts above, I have a unique issue. I’m prototyping algorithms in Julia, for eventually implementation in C on a realtime embedded target. Julia has proved brilliant as a prototyping language and as a result I am enthusiastically advocating for it among my group. But the target software is mission critical and Julia was never in the running.

I don’t know what you mean by a “base” type. A rational is just a pair of integers, and rational calculations on these are pretty easy to implement in C; just look at the Julia implementation in base/rational.jl.

That being said, as I commented above I think the whole idea of looking for times that are exact multiples of dt is probably the wrong direction.

Yes, on reflection I think you are right. I’m going to rewrite it.