From fceb600be574c383dbd286baf609ad27204a6cc0 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 5 Dec 2025 14:45:52 +0100 Subject: [PATCH] math: remove logb As discussed in #12112, this is a false friend (the libc logb() does something else), and without keyword arguments or at least function overloading, this is hard to read. Better use "/ log(base)" trick. --- CHANGELOG.rst | 4 ---- doc_src/cmds/math.rst | 4 +--- src/tinyexpr.rs | 1 - tests/checks/math.fish | 16 +++------------- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fc78be460..80e8dcc25 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,10 +7,6 @@ Notable improvements and fixes Deprecations and removed features --------------------------------- -Scripting improvements ----------------------- -- ``math`` gained a new ``logb`` function. - Interactive improvements ------------------------ - When typing immediately after starting fish, the first prompt is now rendered correctly. diff --git a/doc_src/cmds/math.rst b/doc_src/cmds/math.rst index 4fc886a91..513bad217 100644 --- a/doc_src/cmds/math.rst +++ b/doc_src/cmds/math.rst @@ -153,11 +153,9 @@ Functions ``ln`` the base-e logarithm ``log`` or ``log10`` - the base-10 logarithm + the base-10 logarithm. To compute the logarithm for an arbitrary base ``b``, use ``log(x) / log(b)``. ``log2`` the base-2 logarithm -``logb(b,x)`` - returns the logarithm with base b of x ``max`` returns the largest of the given numbers - this takes an arbitrary number of arguments (but at least one) ``min`` diff --git a/src/tinyexpr.rs b/src/tinyexpr.rs index 13e8e08af..befb02240 100644 --- a/src/tinyexpr.rs +++ b/src/tinyexpr.rs @@ -291,7 +291,6 @@ fn npr(n: f64, r: f64) -> f64 { (L!("log"), Function::Fn1(f64::log10)), (L!("log10"), Function::Fn1(f64::log10)), (L!("log2"), Function::Fn1(f64::log2)), - (L!("logb"), Function::Fn2(|base, x| x.log(base))), (L!("max"), Function::FnN(maximum)), (L!("min"), Function::FnN(minimum)), (L!("ncr"), Function::Fn2(ncr)), diff --git a/tests/checks/math.fish b/tests/checks/math.fish index 9da01e2fa..54d636bca 100644 --- a/tests/checks/math.fish +++ b/tests/checks/math.fish @@ -276,20 +276,10 @@ echo $status math 'log2(8)' # CHECK: 3 -math 'logb(2, 8)' -# CHECK: 3 -math 'logb(67, 406067677556641)' -# CHECK: 8 -math 'logb(42, 230539333248)' -# CHECK: 7 -math 'logb(12, 8916100448256)' -# CHECK: 12 -math 'logb(3, 5559060566555523)' -# CHECK: 33 -math 'logb(5, 2384185791015625)' -# CHECK: 22 -math 'logb(7, 343)' +math 'log(8) / log(2)' # CHECK: 3 +math 'log(625) / log(5)' +# CHECK: 4 # same as sin(cos(2 x pi)) math sin cos 2 x pi