Browse Source

core: fix a bug in real::log() and real::log2() with values smaller than 1.

legacy
Sam Hocevar sam 13 years ago
parent
commit
a66fc123c1
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      src/real.cpp

+ 4
- 2
src/real.cpp View File

@@ -642,7 +642,8 @@ real log(real const &x)
return tmp; return tmp;
} }
tmp.m_signexp = (1 << 30) - 1; 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) real log2(real const &x)
@@ -656,7 +657,8 @@ real log2(real const &x)
return tmp; return tmp;
} }
tmp.m_signexp = (1 << 30) - 1; 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) static real fast_exp(real const &x)


Loading…
Cancel
Save