From 377979b723f0c1bae1ff239ea3d99c0422f7d4a9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 7 Oct 2023 21:26:58 -0400 Subject: Fix puglGetTime() on Apple Silicon The floating point precision of these chips is... strange. --- src/mac.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mac.m b/src/mac.m index fa5355f..07eb28d 100644 --- a/src/mac.m +++ b/src/mac.m @@ -1646,9 +1646,11 @@ puglProcessEvents(PuglView* view) double puglGetTime(const PuglWorld* world) { - return ((double)mach_absolute_time() * world->impl->timebaseInfo.denom / - world->impl->timebaseInfo.numer / 1e9) - - world->startTime; + const struct mach_timebase_info base = world->impl->timebaseInfo; + const double rate = (1.0E9 / base.numer) * base.denom; + const double period = 1.0 / rate; + + return (double)mach_absolute_time() * period; } PuglStatus -- cgit v1.2.1