From d6bcab29201289d86a0d32a9d7fa57fe2e2855b0 Mon Sep 17 00:00:00 2001 From: joba-1 <32450554+joba-1@users.noreply.github.com> Date: Wed, 5 Aug 2020 23:42:34 +0200 Subject: [PATCH] Fix ln(x) via taylor series for special case x = 1 --- tasmota/support_float.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/support_float.ino b/tasmota/support_float.ino index b99b95cd2..697f673a3 100644 --- a/tasmota/support_float.ino +++ b/tasmota/support_float.ino @@ -116,6 +116,7 @@ double TaylorLog(double x) // https://stackoverflow.com/questions/46879166/finding-the-natural-logarithm-of-a-number-using-taylor-series-in-c if (x <= 0.0) { return NAN; } + if (x == 1.0) { return 0; } double z = (x + 1) / (x - 1); // We start from power -1, to make sure we get the right power in each iteration; double step = ((x - 1) * (x - 1)) / ((x + 1) * (x + 1)); // Store step to not have to calculate it each time double totalValue = 0;