Gawk (djgpp) 3.0.3 print error? 
Author Message
 Gawk (djgpp) 3.0.3 print error?

why?

c:\>gawk "BEGIN{OFMT=\"%%012.0f\";print 1}"
1

and

c:\>gawk "BEGIN{OFMT=\"%%012.0f\";print 1.1}"
000000000001

from documentation:

   The built-in variable `OFMT' contains the default format
specification that `print' uses with `sprintf' when it wants to convert
a number to a string for printing.  The default value of `OFMT' is
`"%.6g"'.  By supplying different format specifications as the value of
`OFMT', you can change how `print' will print your numbers

a number not a floating point number!



Tue, 23 Jul 2002 03:00:00 GMT  
 Gawk (djgpp) 3.0.3 print error?
Hi Giacomo,

I think all numbers are floating point numbers in awk.
But, it's only a number when it needs to be a number, any
variable is a string by default.

It seems gawk forgets it saw a 1 and thinks it was a "1".
Surprisingly, when changing it into 1+0 (normally forces it to be a
number) it still does not work.

printf("%012.0f\n", 1) does work, however.

Erik.

Quote:

> from documentation:

>    The built-in variable `OFMT' contains the default format
> specification that `print' uses with `sprintf' when it wants to convert
> a number to a string for printing.  The default value of `OFMT' is
> `"%.6g"'.  By supplying different format specifications as the value of
> `OFMT', you can change how `print' will print your numbers

> a number not a floating point number!



Tue, 23 Jul 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DJGPP gawk and Windows 2000

2. Splitting the DJGPP gawk Docs?

3. looking for DJGPP compilation of gawk v3.1.0.1

4. Gawk 3.1.1 - Question regarding a variable in a print statement and help with code

5. make test error when compiling with djgpp

6. Help with g77/djgpp/Win95 runtime error

7. Gawk for win32 slower than Gawk for Dos_32?

8. Gawk bug, gawk won't nawk.

9. gawk 3.0.95, beta for gawk 3.1.0, now available

10. Error Codes in Gawk 3.1.1b

11. ERROR TERM/0 Print error (COM1)

12. Error TERM / 0 Print error

 

 
Powered by phpBB® Forum Software