第1个回答 2021-09-24
对g的英文说明:
g,G
A double argument representing a floating-point number is converted in
style f or e (or in style F or E in the case of a G conversion specifier),
depending on the value converted and the precision. Let P equal the
precision if nonzero, 6 if the precision is omitted, or 1 if the precision is zero.
Then, if a conversion with style E would have an exponent of X:
— if P > X ≥ −4, the conversion is with style f (or F) and precision
P − (X + 1).
— otherwise, the conversion is with style e (or E) and precision P − 1.
Finally, unless the # flag is used, any trailing zeros are removed from the
fractional portion of the result and the decimal-point character is removed if
there is no fractional portion remaining.
A double argument representing an infinity or NaN is converted in the style
of an f or F conversion specifier.
我这边有两种理解:
一、%e是指数的首字母,%f是浮点数首字母。而%g是两者自动选择。属于e和f的升级版,所以取e、f之后的字母g来表示。
二、英文单词general的首字母。本回答被提问者采纳