[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gawk] type conversion error ascii (hex) to integer
From: |
Stepan Kasal |
Subject: |
Re: [gawk] type conversion error ascii (hex) to integer |
Date: |
Tue, 16 Aug 2005 09:49:46 +0200 |
User-agent: |
Mutt/1.4.1i |
Hello,
On Mon, Aug 15, 2005 at 05:30:51PM -0700, Lee Howard wrote:
> With GNU Awk 3.1.3 as found on Fedora Core 2...
[...]
> awk 'BEGIN { printf(int("0xff")) "\n" };'
>
> The output is "0", not as expected.
use either:
awk --non-decimal-data 'BEGIN { printf(int("0xff")) "\n" };'
awk 'BEGIN { printf(strtonum("0xff")) "\n" };'
And, of course, the following would work, too:
awk 'BEGIN { printf(0xff) "\n" };'
The reasons why conversion of hexadecimal numbers during runtime cannot
be enabled by default are in the manual:
`gawk' allows the use of octal and hexadecimal constants in your
program text. However, such numbers in the input data are not treated
differently; doing so by default would break old programs.
Have a nice day,
Stepan Kasal