From ce91977362139a68e1fbf804c7d4e8a6a2a425c2 Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Thu, 28 Mar 2024 15:40:29 -0700 Subject: [PATCH] Fix FLNP1 calculation (#160) Was log(x)+1 Now log(x+1) Fixes #155 --- csrc/pf_float.h | 1 + csrc/pfinnrfp.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/csrc/pf_float.h b/csrc/pf_float.h index d2b1791..6539efc 100644 --- a/csrc/pf_float.h +++ b/csrc/pf_float.h @@ -36,6 +36,7 @@ typedef double PF_FLOAT; #define fp_floor floor #define fp_log log #define fp_log10 log10 +#define fp_log1p log1p #define fp_pow pow #define fp_sin sin #define fp_sinh sinh diff --git a/csrc/pfinnrfp.h b/csrc/pfinnrfp.h index 4a3095b..3e35185 100644 --- a/csrc/pfinnrfp.h +++ b/csrc/pfinnrfp.h @@ -301,7 +301,7 @@ break; case ID_FP_FLNP1: /* ( -- ) ( F: r1 -- r2 ) */ - FP_TOS = (PF_FLOAT) (fp_log(FP_TOS) + 1.0); + FP_TOS = (PF_FLOAT) fp_log1p(FP_TOS); /* log(x+1) */ break; case ID_FP_FLOG: /* ( -- ) ( F: r1 -- r2 ) */