POSIX Awk says:
The printf statement shall produce output based on a notation similar to the File Format Notation used to describe file formats in this volume of POSIX.1-2008 (see XBD File Format Notation).
And File Format Notation defines %a:
The floating-point number argument representing a floating-point number shall be converted in the style "[-]0xh.hhhhp±d" [...]
However neither Gawk nor Mawk support this:
$ gawk 'BEGIN {printf "%a", 1}'
%a
$ mawk 'BEGIN {printf "%a", 1}'
mawk: run time error: improper conversion(number 1) in printf("%a")
Why is this?
You're looking at the POSIX 2008 SUSv4 (Single Unix Specification) documentation. A lot of software pre-dates this,
gawkincluded. I suspect thegawkimplementation is 2001 SUSv2, and has not been updated completely over time. The Linux (glibc)printf(3)man page alludes to this problem (see the description of%aabout half way through, sorry no anchors to link to):nawk/mawk/gawkdon't simply call the underlying libc'sprintf()orsprintf()verbatim, they more or less reimplement format string processing. Formawksee thedo_printf()function for example. Perl also implements its own format processing, thesprintfman page is more up front about the details.Things which do support
%a/%Aare:printf(i.e./usr/bin/printf)printf, since bash-2.05 if libc has supportsprintfsince perl-5.22.0See the accepted answer here for some additional background: The format specifier %a for printf() in C