Skip to content

[fmt] fix zero-padding behaviour of numbers#2573

Merged
gingerBill merged 1 commit into
odin-lang:masterfrom
inbelic:inbelic/fmt-zero-padding
Jun 7, 2023
Merged

[fmt] fix zero-padding behaviour of numbers#2573
gingerBill merged 1 commit into
odin-lang:masterfrom
inbelic:inbelic/fmt-zero-padding

Conversation

@inbelic

@inbelic inbelic commented Jun 1, 2023

Copy link
Copy Markdown
Contributor
  • when formatting a negative number with left zero-padding we expect the padding to be placed between the minus (-) sign and the number
  • currently the padding is placed before the sign

fixes #2431 and fixes #2328

- when formatting a negative number with left zero-padding we expect the
  padding to be placed between the minus (-) sign and the number
- currently the padding is placed before the sign
@inbelic

inbelic commented Jun 1, 2023

Copy link
Copy Markdown
Contributor Author

Was not entirely sure if we require a guard to check if the string is non-empty in the if statement. It is currently only used in the context of padding numbers and so we can expect it to be non-empty. However, it could be used in a more general case and then we would ensure that we don't have an out-of-bounds error...

@inbelic inbelic marked this pull request as ready for review June 1, 2023 14:11
@gingerBill gingerBill merged commit ae7bf46 into odin-lang:master Jun 7, 2023
@inbelic inbelic deleted the inbelic/fmt-zero-padding branch June 13, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package fmt zero padding of numbers does not work as expected tprintf prints wrong value for negative numbers.

2 participants