printf: make negative values wrap around with unsigned/hex format#7656
printf: make negative values wrap around with unsigned/hex format#7656sylvestre merged 1 commit intouutils:mainfrom
Conversation
|
In terms of readability, I could probably change |
85bf1e2 to
ccf810a
Compare
|
GNU testsuite comparison: |
I think it's ok to hardcode values in tests (worth adding a comment though). |
69bea2b to
c6a7534
Compare
|
Added some more tests cases, checking the overflow value as well. |
|
There's a specific CI which is failing because it thinks that |
|
@eduardorittner you can suppress the error by adding the following to the top of the file: |
|
GNU testsuite comparison: |
Thanks! |
To convert from negative to unsigned with overflow, we get the two's complement representation of the absolute (unsigned) value.
|
GNU testsuite comparison: |
tertsdiepraam
left a comment
There was a problem hiding this comment.
I hate this feature (why is C like this??), but in the name of compatibility I'll approve 😄
When printing unsigned numbers, GNU coreutils makes negative numbers around, so when we try to get a u64 from a BigInt and it's negative, convert it to an i64 and from that to a u64 so it wraps around.
For the test cases I used the same ones as in the original issue #7488
Closes #7488