I read:
The
gandGconversion types choose between floating point or exponential output, depending on the magnitude of the exponent and the value specified for.<precision>. Output is the same ase/Eif the exponent is less than -4 or not less than.<precision>. Otherwise, it’s the same asf/F:
Also, I didnt get "if the exponent is less than -4 or not less than .<precision>". Where do we specify exponent explicitly? By "exponent", does it mean number of digits after decimal point? I feel so, as when I tried to have four digits after decimal points, it printed it as f, but when I tried having five digits after decimal points, it printed it as e:
>>> '%g' % 0.0003
'0.0003'
>>> '%g' % 0.00003
'3e-05'
Q1. Am I correct with above understanding?
Q2. But, then, I didnt get why it did not do same in below example:
>>> '%g' % 3.14
'3.14'
>>> '%g' % 3.014
'3.014'
>>> '%g' % 3.0014
'3.0014'
>>> '%g' % 3.00014
'3.00014'
>>> '%g' % 3.000014
'3.00001'
>>> '%g' % 3.0000014
'3'
Q3. Finally, I didnt get "or not less than .<precision>" part of "if the exponent is less than -4 or not less than .<precision>". I tried to explicitly specify precision less than and more than 4 digits after decimal point. But it still printed the same:
>>> '%g' % 0.00003
'3e-05'
>>> '%.3g' % 0.00003
'3e-05'
>>> '%.9g' % 0.00003
'3e-05'