Fix pow for negative exponents < 1

This commit is contained in:
PaddiM8 2024-04-03 12:27:50 +02:00
parent f846a5b59e
commit d9a63396d6

View File

@ -971,7 +971,7 @@ impl KalkValue {
) => { ) => {
if self.has_imaginary() if self.has_imaginary()
|| imaginary_rhs != &0f64 || imaginary_rhs != &0f64
|| (real_rhs > &0f64 && real_rhs < &1f64) || (real < 0f64 && real_rhs.clone().abs() < 1f64)
{ {
let a = real; let a = real;
let b = imaginary; let b = imaginary;
@ -1576,6 +1576,8 @@ mod tests {
((0f64, 2f64), (0f64, 3f64), (-0.0043748f64, 0.0078460f64)), ((0f64, 2f64), (0f64, 3f64), (-0.0043748f64, 0.0078460f64)),
((3f64, 2f64), (0f64, 3f64), (-0.1304148f64, -0.111153f64)), ((3f64, 2f64), (0f64, 3f64), (-0.1304148f64, -0.111153f64)),
((3f64, 2f64), (4f64, 3f64), (28.8577819f64, -2.422530f64)), ((3f64, 2f64), (4f64, 3f64), (28.8577819f64, -2.422530f64)),
((-9f64, 0f64), (0.5f64, 0f64), (0f64, 3f64)),
((-9f64, 0f64), (-0.5f64, 0f64), (0f64, -1f64 / 3f64)),
( (
(3f64, 0f64), (3f64, 0f64),
(0f64, 1f64 / 3f64), (0f64, 1f64 / 3f64),