From 781eeaa4a670bbea4df76273ba77eb4df08ceeaf Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Tue, 13 May 2008 10:43:14 +0000 Subject: [PATCH] Avoid using doubles for GetTimeSinceStart(). --- stepmania/src/RageTimer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/stepmania/src/RageTimer.cpp b/stepmania/src/RageTimer.cpp index 1e06fc5380..8b15b3341b 100644 --- a/stepmania/src/RageTimer.cpp +++ b/stepmania/src/RageTimer.cpp @@ -23,6 +23,7 @@ #include "RageTimer.h" #include "RageLog.h" +#include "RageUtil.h" #include "arch/ArchHooks/ArchHooks.h" @@ -49,12 +50,12 @@ static uint64_t GetTime( bool bAccurate ) float RageTimer::GetTimeSinceStart( bool bAccurate ) { - int64_t usecs = GetTime( bAccurate ); + uint64_t usecs = GetTime( bAccurate ); usecs -= g_iStartTime; - // HACK: VC6 can't cast u64 to a double, but it can cast a i64 to a double. - // We can afford to lose one bit of precision since these numbers will - // never overflow a 64 int. - return float( double(usecs) / 1000000. ); + /* Avoid using doubles for hardware that doesn't support them. + * This is writing usecs = high*2^32 + low and doing + * usecs/10^6 = high * (2^32/10^6) + low/10^6. */ + return uint32_t(usecs>>32) * 4294.967296f + uint32_t(usecs)/1000000.f; } void RageTimer::Touch()