(self, other: Self)
| 562 | } |
| 563 | |
| 564 | fn sdiv(self, other: Self) -> ValueResult<Self> { |
| 565 | if self.is_float() { |
| 566 | return binary_match!(/(self, other); [F32, F64]); |
| 567 | } |
| 568 | |
| 569 | let denominator = other.clone().into_int_signed()?; |
| 570 | |
| 571 | // Check if we are dividing INT_MIN / -1. This causes an integer overflow trap. |
| 572 | let min = DataValueExt::int(1i128 << (self.ty().bits() - 1), self.ty())?; |
| 573 | if self == min && denominator == -1 { |
| 574 | return Err(ValueError::IntegerOverflow); |
| 575 | } |
| 576 | |
| 577 | if denominator == 0 { |
| 578 | return Err(ValueError::IntegerDivisionByZero); |
| 579 | } |
| 580 | |
| 581 | binary_match!(/(&self, &other); [I8, I16, I32, I64, I128]) |
| 582 | } |
| 583 | |
| 584 | fn udiv(self, other: Self) -> ValueResult<Self> { |
| 585 | if self.is_float() { |
no test coverage detected