NetBSD-Bugs archive

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

Re: bin/48017: awk(1) fails to treat var as integer (may be related to #47840)



The following reply was made to PR bin/48017; it has been noted by GNATS.

From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/48017: awk(1) fails to treat var as integer (may be related
 to #47840)
Date: Tue, 9 Jul 2013 18:21:54 +0000

 On Fri, Jul 05, 2013 at 09:50:00PM +0000, Steffen Daode Nurpmeso wrote:
  >  Hmmm.
  >  [6 slightly different cases]
 
 Is this what you're getting at?
 
 echo f001 f00d | awk '{ a="0x" $1; b="0x" $2; while (a < b) { print a; a++; }}'
 0xf001
 
 vs.
 
  echo f001 f00d | awk '{ a="0x" $1; b="0x" $2; a+=0; b+=0; while (a < b) { 
print a; a++; }}'
 61441
 61442
 61443
 61444
 61445
 61446
 61447
 61448
 61449
 61450
 61451
 61452
 
 sprintf witih %d doesn't produce an number value; it produces a
 string value, which you have to coerce to a number by adding zero to
 it to get it to behave like a number.
 
 -- 
 David A. Holland
 dholland%netbsd.org@localhost
 


Home | Main Index | Thread Index | Old Index