[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [MISC] Awk underlighed



On Tue, Jul 31, 2001 at 19:00:21 +0000, Henrik Størner wrote:

>    echo "0xf" | awk '{ printf ("%04X\n", $1*4) }'

> Nogen awk-eksperter der kan forklare om det er en fejl i gawk 3.1.0,
> eller der er en god grund til at den gør som den gør ?

gawk 3.0.3 giver "0000"
gawk 3.0.4 giver "0007" som også er forkert!


gawk(1):

       When  a  string must be converted to a number, the conver­
       sion is accomplished using atof(3).  A number is converted
                        ******************
       to  a  string  by  using  the value of CONVFMT as a format
       string for sprintf(3), with the numeric value of the vari­
       able as the argument.  However, even though all numbers in
       AWK are floating-point, integral values  are  always  con­
       verted as integers.  Thus, given

              CONVFMT = "%2.2f"
              a = 12
              b = a ""

       the variable b has a string value of "12" and not "12.00".


Så vidt jeg kan se kan man ikke autokonvertere til hex,
i hvert fald ikke i de "gamle" gawk versioner jeg har.


PS.
brug "gawk", der er lidt forskel på awk og gawk, men ikke
i denne forbindelse.


-- 
mvh Frank Damgaard  | http://home3.inet.tele.dk/frda/



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 19:23 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *