From fd2d9c214c7bab39174b40427ad83ee899f5e916 Mon Sep 17 00:00:00 2001 From: hazohelet <48541090+hazohelet@users.noreply.github.com> Date: Sat, 28 Sep 2019 20:04:03 +0900 Subject: [PATCH] f64: fix .eq() --- vlib/builtin/int.v | 3 +-- vlib/math/math_test.v | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index de20dae328..5543d9475d 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -27,8 +27,7 @@ pub fn ptr_str(ptr voidptr) string { // compare floats using C epsilon pub fn (a f64) eq(b f64) bool { - //return C.fabs(a - b) <= C.DBL_EPSILON - return (a - b) <= C.DBL_EPSILON + return C.fabs(a - b) <= C.DBL_EPSILON } // fn (nn i32) str() string { diff --git a/vlib/math/math_test.v b/vlib/math/math_test.v index a76d187e44..c52300b7db 100644 --- a/vlib/math/math_test.v +++ b/vlib/math/math_test.v @@ -46,5 +46,5 @@ fn test_erf() { fn test_gamma() { assert math.gamma(1) == 1 assert math.gamma(5) == 24 - assert math.log_gamma(4.5) == math.log(math.gamma(4.5)) + assert math.log_gamma(4.5).eq(math.log(math.gamma(4.5))) }