| ... | ... | @@ -512,17 +512,19 @@ pub fn bufPrintInt(out_buf: []u8, x: var, base: u8, uppercase: bool, width: usiz |
| 512 | 512 | |
| 513 | 513 | fn bufPrintSigned(out_buf: []u8, x: var, base: u8, uppercase: bool, width: usize) -> usize { |
| 514 | 514 | const uint = @intType(false, @typeOf(x).bit_count); |
| 515 | | // include the sign in the width |
| 516 | | const new_width = if (width == 0) 0 else (width - 1); |
| 517 | | var new_value: uint = undefined; |
| 518 | 515 | if (x < 0) { |
| 519 | 516 | out_buf[0] = '-'; |
| 520 | | new_value = uint(-(x + 1)) + 1; |
| 517 | const new_value = uint(-(x + 1)) + 1; |
| 518 | const new_width = if (width == 0) 0 else (width - 1); |
| 519 | return 1 + bufPrintUnsigned(out_buf[1...], new_value, base, uppercase, new_width); |
| 520 | } else if (width == 0) { |
| 521 | return bufPrintUnsigned(out_buf, uint(x), base, uppercase, width); |
| 521 | 522 | } else { |
| 522 | 523 | out_buf[0] = '+'; |
| 523 | | new_value = uint(x); |
| 524 | const new_value = uint(x); |
| 525 | const new_width = if (width == 0) 0 else (width - 1); |
| 526 | return 1 + bufPrintUnsigned(out_buf[1...], new_value, base, uppercase, new_width); |
| 524 | 527 | } |
| 525 | | return 1 + bufPrintUnsigned(out_buf[1...], new_value, base, uppercase, new_width); |
| 526 | 528 | } |
| 527 | 529 | |
| 528 | 530 | fn bufPrintUnsigned(out_buf: []u8, x: var, base: u8, uppercase: bool, width: usize) -> usize { |