bug-gnu-utils
[Top][All Lists]
Advanced

[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 17:17:50 +0200
User-agent: Mutt/1.4.1i

Hello,

On Tue, Aug 16, 2005 at 07:59:06AM -0700, Lee Howard wrote:
> >awk 'BEGIN { printf(strtonum("0xff")) "\n" };'
...
> Unfortunately, neither --non-decimal-data nor strtonum are portable.

Sure, there is no portable solution.  It was shere good luck if your
solution worked on more platforms.  POSIX prohibits hexadecimal numbers
even in program code.

But strtonum can be implemented as a user function; actually, it comes
as an example with gawk.  It's installed as /usr/share/awk/strtonum.awk
on my GNU/Linux system.


BTW, int() is truncation, like trunc() or floor() in C.  (POSIX doesn't
specify which one of them.)  It would have been more awkish to write:
        awk 'BEGIN { printf("0xff" + 0) "\n" };'

Have a nice day,
        Stepan Kasal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]