Skip to content

Commit

Permalink
remove pow10 in favor of exp10, define scalbn and scalbln by ldexp
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Mar 3, 2024
1 parent 0a38bb1 commit 7bbee36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
5 changes: 2 additions & 3 deletions cli/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 3 additions & 12 deletions func.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 7bbee36

Please sign in to comment.