From b81e4138324ddda945535065e8ef78382cf5a1c8 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Tue, 29 Nov 2005 20:04:27 +0000
Subject: [PATCH] MSVCs long double does *not* have 19 significant digits which
 is required to be able to accurately cast a long long int to a long double. 
 Replace: (long double)x/y WITH (x/y)+((long double)(x%y)/y)

Can everyone look for a problem with assuming those two are interchangeable
with the second being more accurate?
---
 src/xpdev/genwrap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c
index 559d7c1809..196924e65b 100644
--- a/src/xpdev/genwrap.c
+++ b/src/xpdev/genwrap.c
@@ -514,7 +514,9 @@ long double	DLLCALL	xp_timer(void)
 		ret=((long double)tick.HighPart*4294967296)+((long double)tick.LowPart);
 		ret /= ((long double)freq.HighPart*4294967296)+((long double)freq.LowPart);
 #else
-		ret=((long double)tick.QuadPart)/freq.QuadPart;
+		/* In MSVC, a long double does NOT have 19 decimals of precision */
+		ret=((long int)(tick.QuadPart/freq.QuadPart))
+				+(((long double)(tick.QuadPart%freq.QuadPart))/freq.QuadPart);
 #endif
 	}
 	else {
-- 
GitLab