From 7bbee362d80c45a5dac215438fa96c5eb86f6d09 Mon Sep 17 00:00:00 2001 From: itchyny Date: Sun, 3 Mar 2024 20:15:57 +0900 Subject: [PATCH] remove pow10 in favor of exp10, define scalbn and scalbln by ldexp --- cli/test.yaml | 5 ++--- func.go | 15 +++------------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/cli/test.yaml b/cli/test.yaml index 97920c2f..7369106d 100644 --- a/cli/test.yaml +++ b/cli/test.yaml @@ -4028,17 +4028,16 @@ expected: | [0,-1,1,-1.5,1,1.25,1,1.5625] -- name: exp, exp10, exp2, expm1, pow10 functions +- name: exp, exp10, exp2, expm1 functions args: - -c - - 'map(exp), map(exp10), map(exp2), map(expm1), map(pow10) | map(. * 1000000000 | floor / 1000000000)' + - 'map(exp), map(exp10), map(exp2), map(expm1) | map(. * 1000000000 | floor / 1000000000)' input: '[0, -0.5, 1, -1.5, 2, 10, 100, 300]' expected: | [1,0.606530659,2.718281828,0.22313016,7.389056098,22026.465794806,2.6881171418161356e+43,1.9424263952412558e+130] [1,0.316227766,10,0.031622776,100,10000000000,1.0000000000000002e+100,1.7976931348623157e+308] [1,0.707106781,2,0.35355339,4,1024,1.2676506002282294e+30,2.037035976334486e+90] [0,-0.393469341,1.718281828,-0.77686984,6.389056098,22025.465794806,2.6881171418161356e+43,1.9424263952412558e+130] - [1,0.316227766,10,0.031622776,100,10000000000,1.0000000000000002e+100,1.7976931348623157e+308] - name: frexp, modf function args: diff --git a/func.go b/func.go index c6936f16..f5319500 100644 --- a/func.go +++ b/func.go @@ -165,15 +165,14 @@ func init() { "fmod": mathFunc2("fmod", math.Mod), "hypot": mathFunc2("hypot", math.Hypot), "jn": mathFunc2("jn", funcJn), - "ldexp": mathFunc2("ldexp", funcLdexp), "nextafter": mathFunc2("nextafter", math.Nextafter), "nexttoward": mathFunc2("nexttoward", math.Nextafter), "remainder": mathFunc2("remainder", math.Remainder), - "scalb": mathFunc2("scalb", funcScalb), - "scalbln": mathFunc2("scalbln", funcScalbln), + "ldexp": mathFunc2("ldexp", funcLdexp), + "scalb": mathFunc2("scalb", funcLdexp), + "scalbln": mathFunc2("scalbln", funcLdexp), "yn": mathFunc2("yn", funcYn), "pow": mathFunc2("pow", math.Pow), - "pow10": mathFunc("pow10", funcExp10), "fma": mathFunc3("fma", math.FMA), "infinite": argFunc0(funcInfinite), "isfinite": argFunc0(funcIsfinite), @@ -1411,14 +1410,6 @@ func funcLdexp(l, r float64) float64 { return math.Ldexp(l, int(r)) } -func funcScalb(l, r float64) float64 { - return l * math.Pow(2, r) -} - -func funcScalbln(l, r float64) float64 { - return l * math.Pow(2, r) -} - func funcYn(l, r float64) float64 { return math.Yn(int(l), r) }