Me, I’d do ('%f' % x).rstrip('0').rstrip('.')
— guarantees fixed-point formatting rather than scientific notation, etc etc. Yeah, not as slick and elegant as %g
, but, it works (and I don’t know how to force %g
to never use scientific notation;-).
More Related Contents:
- How to prettyprint a JSON file?
- Format floats with standard json module
- Easy pretty printing of floats?
- How do I check if a string is a number (float)?
- How to use a decimal range() step value?
- How do you round UP a number?
- Currency formatting in Python
- How to truncate float values?
- How to print float to n decimal places including trailing 0s?
- How to round a floating point number up to a certain decimal place?
- Python float – str – float weirdness
- Range values to pseudocolor
- formatting long numbers as strings in python
- Testing floating point equality
- Python datetime formatting without zero-padding
- Convert hex to float
- Declare function at end of file in Python [duplicate]
- rounding errors in Python floor division
- Python pretty XML printer with lxml
- Format certain floating dataframe columns into percentage in pandas
- What is the range of values a float can have in Python?
- Python floating point number comparison
- Function to determine if two numbers are nearly equal when rounded to n significant decimal digits
- How to Print “Pretty” String Output in Python
- How to get largest possible precision? (Python – Decimal)
- Python, print all floats to 2 decimal places in output
- What are some possible calculations with numpy or scipy that can return a NaN? [closed]
- How do you get the next value in the floating-point sequence? [duplicate]
- on what systems does Python not use IEEE-754 double precision floats
- Print a float number in normal form, not exponential form / scientific notation [duplicate]