About 211,000 results
Open links in new tab
  1. python - Limiting floats to two decimal points - Stack Overflow

    Jan 19, 2009 · These conversions occur in many different places: str () on floats and complex numbers; the float and complex constructors; numeric formatting; serializing and de-serializing …

  2. python - How can I format a decimal to always show 2 decimal …

    Regardless of the length of the decimal or whether there are are any decimal places, I would like to display a Decimal with 2 decimal places, and I'd like to do it in an efficient way.

  3. python - How to display a float with two decimal places ... - Stack ...

    I have a function taking float arguments (generally integers or decimals with one significant digit), and I need to output the values in a string with two decimal places (5 → 5.00, 5.5 → 5.50, etc)...

  4. Python 3 Float Decimal Points/Precision - Stack Overflow

    In Python 3 however, float(-3.65) returns -3.6499999999999999 which loses its precision. I want to print the list of floats, [-3.6499999999999999, 9.1699999999999999, 1.0] with 2 decimal …

  5. more decimal places needed in python - Stack Overflow

    I am writing a python code, which needs to asses number to very many decimal places - around 14 or 15. I expect results that increase smoothly, for example: 0.123456789101997 …

  6. python - Fixed digits after decimal with f-strings - Stack Overflow

    Is there an easy way with Python f-strings to fix the number of digits after the decimal point? (Specifically f-strings, not other string formatting options like .format or %) For example, let's s...

  7. How to round to 2 decimals with Python? - Stack Overflow

    Dec 9, 2013 · 75 If you just want to print the rounded result out, you can use the f-strings introduced since Python 3.6. The syntax is the same as str.format() 's format string syntax, …

  8. Specifying number of decimal places in Python - Stack Overflow

    Specifying number of decimal places in Python Asked 15 years, 6 months ago Modified 3 years, 2 months ago Viewed 177k times

  9. python - How to truncate float values? - Stack Overflow

    By multiplying the number by 1000 (10 ^ 3 for 3 digits) we shift the decimal point 3 places to the right and get 1923.3284374520001. When we convert that to an int the fractional part …

  10. python - How to round a floating point number up to a certain …

    Jan 22, 2015 · Here, num is the decimal number. x is the decimal up to where you want to round a floating number. The advantage over other implementation is that it can fill zeros at the right …