Using Bash 5.0.17(1)-release
Performing:
LC_NUMERIC=C printf '%a\n' 0.0
Outputs:
0x0p+0
Testing multiple values:
for v in 1.0 2.0 42.0 3.141592653589793
do LC_NUMERIC=C printf '%-20s %a\n' "$v" "$v"
done
Output is:
1.0 0x8p-3
2.0 0x8p-2
42.0 0xa.8p+2
3.141592653589793 0xc.90fdaa22168bde9p-2
What is this %a
format specifier, I could not find documented with man bash
or help printf
or searching the web?
What is this
%a
format specifier, I could not find documented withman bash
orhelp printf
or searching the web?
It provides the same function as the same format specifier used with the C standard library's printf()
function. Specifically, it prints a hexadecimal representation of a floating-point number.