From a66fc123c167abb67d23f6d51c12c8421b6a0736 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 12 Oct 2011 23:31:11 +0000 Subject: [PATCH] core: fix a bug in real::log() and real::log2() with values smaller than 1. --- src/real.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/real.cpp b/src/real.cpp index aae114e5..16b9914b 100644 --- a/src/real.cpp +++ b/src/real.cpp @@ -642,7 +642,8 @@ real log(real const &x) return tmp; } tmp.m_signexp = (1 << 30) - 1; - return (real)(x.m_signexp - (1 << 30) + 1) * real::R_LN2 + fast_log(tmp); + return (real)(int)(x.m_signexp - (1 << 30) + 1) * real::R_LN2 + + fast_log(tmp); } real log2(real const &x) @@ -656,7 +657,8 @@ real log2(real const &x) return tmp; } tmp.m_signexp = (1 << 30) - 1; - return (real)(x.m_signexp - (1 << 30) + 1) + fast_log(tmp) * real::R_LOG2E; + return (real)(int)(x.m_signexp - (1 << 30) + 1) + + fast_log(tmp) * real::R_LOG2E; } static real fast_exp(real const &x)