From 91690a1b5483268e5bc9f8af4f104210eee52113 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 13 Oct 2019 04:27:57 +0300 Subject: [PATCH] fix f64 tcc eq crash --- vlib/builtin/int.v | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index d2a3699db7..f3e61fa965 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -28,18 +28,26 @@ pub fn ptr_str(ptr voidptr) string { // compare floats using C epsilon // == pub fn (a f64) eq(b f64) bool { - $if tinyc { - return a -b <= 0.01 + $if windows { + $if tinyc { + return a -b <= 0.01 + } $else { + return C.fabs(a - b) <= C.DBL_EPSILON + } } $else { - return C.fabs(a - b) <= C.DBL_EPSILON + return C.fabs(a - b) <= C.DBL_EPSILON } } pub fn (a f32) eq(b f32) bool { - $if tinyc { - return a -b <= 0.01 + $if windows { + $if tinyc { + return a -b <= 0.01 + } $else { + return C.fabs(a - b) <= C.DBL_EPSILON + } } $else { - return C.fabsf(a - b) <= C.FLT_EPSILON -} + return C.fabs(a - b) <= C.DBL_EPSILON + } } pub fn (a f64) eqbit(b f64) bool { return C.DEFAULT_EQUAL(a, b)