Commit 45bf384
committed
Fix doubled negative sign in fractional() for negative mixed numbers
fractional(-1.3) returned '-1 -3/10' instead of '-1 3/10', and
fractional(-2.5) returned '-2 -1/2'. The whole-number part already
carries the sign (int(-1.3) == -1), so the numerator should not repeat
it. This was inconsistent with the pure-fraction case, which is already
correct (fractional(-0.3) == '-3/10').
Use abs(numerator) in the mixed-fraction output. Add regression cases
(-0.3, -1.3, -2.5) to the parametrized test_fractional, which previously
had no negative inputs.1 parent 976484a commit 45bf384
2 files changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
370 | | - | |
| 370 | + | |
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
0 commit comments