简体   繁体   English

这个 bash 内置的 printf 的 %a 格式说明符是什么?

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

Using Bash 5.0.17(1)-release使用 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: Output 是:

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?这个%a格式help printf man bash是什么?

What is this %a format specifier, I could not find documented with man bash or help printf or searching the web?这个%a格式help printf man bash是什么?

It provides the same function as the same format specifier used with the C standard library's printf() function.它提供了与 C 标准库的printf() function 一起使用的相同格式说明符的 function。 Specifically, it prints a hexadecimal representation of a floating-point number.具体来说,它打印浮点数的十六进制表示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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