From 9514c152bce1471984f229537dec5b6d5f74cbf9 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 16 Oct 2023 17:08:19 -0700 Subject: [PATCH] Fixed precision on Windows --- src/vector.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vector.c b/src/vector.c index f6c5abc..7b70c7e 100644 --- a/src/vector.c +++ b/src/vector.c @@ -755,7 +755,12 @@ normalize_l2(PG_FUNCTION_ARGS) Vector *a = PG_GETARG_VECTOR_P(0); float *ax = a->x; double norm = 0.0; +#ifdef _MSC_VER + /* Fix precision on Windows */ + double normf; +#else float normf; +#endif Vector *result; float *rx; @@ -767,7 +772,7 @@ normalize_l2(PG_FUNCTION_ARGS) norm += (double) ax[i] * (double) ax[i]; norm = sqrt(norm); - normf = (float) norm; + normf = norm; if (normf > 0) {