| ... | @@ -25,7 +25,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{ | ... | @@ -25,7 +25,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{ |
| 25 | | 25 | |
| 26 | // powi(x, +-0) = 1 for any x | 26 | // powi(x, +-0) = 1 for any x |
| 27 | if (y == 0 or y == -0) { | 27 | if (y == 0 or y == -0) { |
| 28 | return 0; | 28 | return 1; |
| 29 | } | 29 | } |
| 30 | | 30 | |
| 31 | switch (x) { | 31 | switch (x) { |
| ... | @@ -174,4 +174,11 @@ test "math.powi.special" { | ... | @@ -174,4 +174,11 @@ test "math.powi.special" { |
| 174 | testing.expectError(error.Overflow, powi(u64, 2, 64)); | 174 | testing.expectError(error.Overflow, powi(u64, 2, 64)); |
| 175 | testing.expectError(error.Overflow, powi(u17, 2, 17)); | 175 | testing.expectError(error.Overflow, powi(u17, 2, 17)); |
| 176 | testing.expectError(error.Overflow, powi(u42, 2, 42)); | 176 | testing.expectError(error.Overflow, powi(u42, 2, 42)); |
| | 177 | |
| | 178 | testing.expect((try powi(u8, 6, 0)) == 1); |
| | 179 | testing.expect((try powi(u16, 5, 0)) == 1); |
| | 180 | testing.expect((try powi(u32, 12, 0)) == 1); |
| | 181 | testing.expect((try powi(u64, 34, 0)) == 1); |
| | 182 | testing.expect((try powi(u17, 16, 0)) == 1); |
| | 183 | testing.expect((try powi(u42, 34, 0)) == 1); |
| 177 | } | 184 | } |