Python Forum
precision in formatting float
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
precision in formatting float
#1
Quote:The precision is a decimal number indicating how many digits should be displayed after the decimal point for a floating point value formatted with 'f' and 'F', or before and after the decimal point for a floating point value formatted with 'g' or 'G'.

the library reference for 3.7.2 says the above, specifically "after the decimal point". yet, what i find resulting from format() is that the precision value includes the decimal point itself. by setting the precision to 6, i get 5 decimal digits after the decimal point.

has anyone else observed this? i don't know whether this is a bug or a documentation error.

i am using 3.6.9 and reading docs for 3.7.2 because PDF was messed up for 3.6. i wonder if any of this has changed in later versions.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
precision in formatting float - by Skaperen - Apr-30-2022, 09:43 PM
RE: precision in formatting float - by snippsat - May-01-2022, 08:12 AM
RE: precision in formatting float - by Skaperen - May-01-2022, 10:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  quest for better float formatting Skaperen 0 1,707 Mar-02-2022, 08:34 PM
Last Post: Skaperen
  functio to do fixed formatting of int/float Skaperen 0 2,503 Dec-26-2018, 09:55 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020