bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The correct way to print hex number as dec number?


From: david kerns
Subject: Re: The correct way to print hex number as dec number?
Date: Fri, 13 Mar 2020 09:39:15 -0700

I don't see that issue... but your syntax looks overly complicated...

$ echo 0xaaaa | awk '{printf("%d\n", $1)}'
43690

what shell are you running? Is your shell generating literal binary data,
or a string representation of the hex?

On Fri, Mar 13, 2020 at 9:30 AM Peng Yu <address@hidden> wrote:

> Hi,
>
> I see that --non-decimal-data must be used to print hex number as a
> dec number. Is it the correct way to do so? I'd like to control this a
> finer scale. Is there a way to dictate which column this option is
> effective? Thanks.
>
> $ awk --non-decimal-data '{ printf("%d\n", $1) }' <<< '0xaaaa'
> 43690
> $ awk '{ printf("%d\n", $1) }' <<< '0xaaaa'
> 0
>
> --
> Regards,
> Peng
>
>


reply via email to

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