Commit 331b4c6
committed
fractional: stop printing two minus signs for a negative mixed number
int() truncates toward zero, so int(-1.3) is -1 and (-1.3) - (-1) is
-0.3, which Fraction turns into -3/10. Both the whole-number part and
the numerator end up signed and the output reads as "-1 -3/10".
The minus sign already rides on the whole-number part; absorb it
from the numerator so the result is the conventional "-1 3/10".
Added a few negative cases to test_fractional.
Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>1 parent 013969a commit 331b4c6
2 files changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
370 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
371 | 376 | | |
372 | 377 | | |
373 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
| |||
0 commit comments