Function
safe_division_d
(
numerator, # Changed
denominator, # Changed
*,
ignore_overflow=False,
ignore_zero_division=False
)
Source from the content-addressed store, hash-verified
| 162 | |
| 163 | print("Example 11") |
| 164 | def safe_division_d( |
| 165 | numerator, # Changed |
| 166 | denominator, # Changed |
| 167 | *, |
| 168 | ignore_overflow=False, |
| 169 | ignore_zero_division=False |
| 170 | ): |
| 171 | try: |
| 172 | return numerator / denominator |
| 173 | except OverflowError: |
| 174 | if ignore_overflow: |
| 175 | return 0 |
| 176 | else: |
| 177 | raise |
| 178 | except ZeroDivisionError: |
| 179 | if ignore_zero_division: |
| 180 | return float("inf") |
| 181 | else: |
| 182 | raise |
| 183 | |
| 184 | |
| 185 | print("Example 12") |
Tested by
no test coverage detected