diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-13 20:10:29 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-13 20:10:29 +0100 |
| commit | cb3c263c4a67f4d361dbdb5048a1c073bd1fff96 (patch) | |
| tree | 4b1a2332cb21cce6699428cab474dc1ea606da41 /library/src/compute | |
| parent | 8debba439cbaa02faddcd3797841d7232d82e820 (diff) | |
More accurate logarithm for base 2 and 10
Diffstat (limited to 'library/src/compute')
| -rw-r--r-- | library/src/compute/calc.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs index 25df817d..7fcc6131 100644 --- a/library/src/compute/calc.rs +++ b/library/src/compute/calc.rs @@ -366,7 +366,13 @@ pub fn log( #[default(10.0)] base: f64, ) -> Value { - Value::Float(value.log(base)) + Value::Float(if base == 2.0 { + value.log2() + } else if base == 10.0 { + value.log10() + } else { + value.log(base) + }) } /// Round a number down to the nearest integer. |
