mirror of
https://github.com/vlang/v.git
synced 2025-09-10 16:00:31 -04:00
math: fix expected results for -5 raised to the -2 power, add a few more cases (#19274)
This commit is contained in:
parent
fb0f12f937
commit
c126450201
@ -777,7 +777,8 @@ fn test_pow() {
|
|||||||
[inf(1), 1], [inf(1), pi], [inf(1), nan()], [nan(), -pi],
|
[inf(1), 1], [inf(1), pi], [inf(1), nan()], [nan(), -pi],
|
||||||
[nan(), -0.0], [nan(), 0], [nan(), 1], [nan(), pi], [nan(),
|
[nan(), -0.0], [nan(), 0], [nan(), 1], [nan(), pi], [nan(),
|
||||||
nan()],
|
nan()],
|
||||||
[5.0, 2.0], [5.0, 3.0], [5.0, 10.0], [5.0, -2.0], [-5.0, -2.0]]
|
[5.0, 2.0], [5.0, 3.0], [5.0, 10.0], [5.0, -2.0], [-5.0, -1.0],
|
||||||
|
[-5.0, -2.0], [-5.0, -3.0]]
|
||||||
pow_sc_ := [f64(0), // pow(-inf, -pi)
|
pow_sc_ := [f64(0), // pow(-inf, -pi)
|
||||||
-0.0, // pow(-inf, -3)
|
-0.0, // pow(-inf, -3)
|
||||||
1, // pow(-inf, -0)
|
1, // pow(-inf, -0)
|
||||||
@ -844,11 +845,13 @@ fn test_pow() {
|
|||||||
125, // pow(5, 3) => 5 * 5 * 5
|
125, // pow(5, 3) => 5 * 5 * 5
|
||||||
9765625, // pow(5, 10)
|
9765625, // pow(5, 10)
|
||||||
0.04, // pow(5, -2)
|
0.04, // pow(5, -2)
|
||||||
-0.04, // pow(-5, -2)
|
-0.2, // pow(-5, -1)
|
||||||
|
0.04, // pow(-5, -2)
|
||||||
|
-0.008, // pow(-5, -3)
|
||||||
]
|
]
|
||||||
for i := 0; i < vfpow_sc_.len; i++ {
|
for i := 0; i < vfpow_sc_.len; i++ {
|
||||||
f := pow(vfpow_sc_[i][0], vfpow_sc_[i][1])
|
f := pow(vfpow_sc_[i][0], vfpow_sc_[i][1])
|
||||||
assert alike(pow_sc_[i], f)
|
assert alike(pow_sc_[i], f), 'pow_sc_[${i}] = ${pow_sc_[i]}, f = ${f}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user