coreutils
coreutils copied to clipboard
printf: negative numbers should wrap around when printed as unsigned/hexadecimal (`%u`/`%x`)
In GNU coreutils, negative numbers wrap around (64-bit integer), but uutils rejects them:
$ env printf "%x\n" -0b100; env printf "%x\n" -0100; env printf "%x\n" -100; env printf "%x\n" -0x100
fffffffffffffffc
ffffffffffffffc0
ffffffffffffff9c
ffffffffffffff00
$ cargo run printf "%x\n" -0b100; cargo run printf "%x\n" -100; cargo run printf "%x\n" -0x100
printf: '-0b100': expected a numeric value
0
printf: '-0100': expected a numeric value
0
printf: '-100': expected a numeric value
0
printf: '-0x100': expected a numeric value
0