| 1 | class DivisionOperation: |
| 2 | INT_MAX = float("inf") |
| 3 | |
| 4 | def __init__(self, num1, num2): |
| 5 | self.num1 = num1 |
| 6 | self.num2 = num2 |
| 7 | |
| 8 | def perform_division(self): |
| 9 | if self.num1 == 0: |
| 10 | return 0 |
| 11 | if self.num2 == 0: |
| 12 | return self.INT_MAX |
| 13 | |
| 14 | neg_result = False |
| 15 | |
| 16 | # Handling negative numbers |
| 17 | if self.num1 < 0: |
| 18 | self.num1 = -self.num1 |
| 19 | |
| 20 | if self.num2 < 0: |
| 21 | self.num2 = -self.num2 |
| 22 | else: |
| 23 | neg_result = True |
| 24 | elif self.num2 < 0: |
| 25 | self.num2 = -self.num2 |
| 26 | neg_result = True |
| 27 | |
| 28 | quotient = 0 |
| 29 | |
| 30 | while self.num1 >= self.num2: |
| 31 | self.num1 -= self.num2 |
| 32 | quotient += 1 |
| 33 | |
| 34 | if neg_result: |
| 35 | quotient = -quotient |
| 36 | return quotient |
| 37 | |
| 38 | |
| 39 | # Driver program |