Skip to content

Commit d9a6339

Browse files
committed
Fix pow for negative exponents < 1
1 parent f846a5b commit d9a6339

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kalk/src/kalk_value/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ impl KalkValue {
971971
) => {
972972
if self.has_imaginary()
973973
|| imaginary_rhs != &0f64
974-
|| (real_rhs > &0f64 && real_rhs < &1f64)
974+
|| (real < 0f64 && real_rhs.clone().abs() < 1f64)
975975
{
976976
let a = real;
977977
let b = imaginary;
@@ -1576,6 +1576,8 @@ mod tests {
15761576
((0f64, 2f64), (0f64, 3f64), (-0.0043748f64, 0.0078460f64)),
15771577
((3f64, 2f64), (0f64, 3f64), (-0.1304148f64, -0.111153f64)),
15781578
((3f64, 2f64), (4f64, 3f64), (28.8577819f64, -2.422530f64)),
1579+
((-9f64, 0f64), (0.5f64, 0f64), (0f64, 3f64)),
1580+
((-9f64, 0f64), (-0.5f64, 0f64), (0f64, -1f64 / 3f64)),
15791581
(
15801582
(3f64, 0f64),
15811583
(0f64, 1f64 / 3f64),

0 commit comments

Comments
 (0)