简体   繁体   中英

What is this bash built-in's printf's %a format specifier?

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 with man bash or help 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM