in reply to golf anyone? (hexdump)
On a related note does anyone know why the sprintf format "%#x" behaves differently for 0 than for other numbers.sub hexout4 { "@{[unpack('H*',pop)=~/../g]}" }
printf "%#x\n", 0; printf "%#x\n", 1; __END__ Prints: 0 0x1
I guess that the behaviour comes from the C compiler that builds perl because the following gives the same results (at least where I could test it):
int main () { printf("%#x\n", 0); printf("%#x\n", 1); return 0; }
So why is 0 treated differently?
--
John.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: golf anyone? (hexdump)
by John M. Dlugosz (Monsignor) on Aug 09, 2002 at 15:05 UTC |