I think it reflects more on your understanding of floating point types than on Python. See my article about floating point numbers (.NET-based, but still relevant) for the reasons behind this “inaccuracy”. If you need to keep the exact decimal representation, you should use the decimal module.
Related Contents:
- Limiting floats to two decimal points
- Is floating point arbitrary precision available?
- How to properly round-up half float numbers?
- negative zero in python
- Why does the floating-point value of 4*0.1 look nice in Python 3 but 3*0.1 doesn’t?
- Python float – str – float weirdness
- python floating number [duplicate]
- Determine precision and scale of particular number in Python
- How do I parse a string to a float or int?
- How can I force division to be floating point? Division keeps rounding down to 0?
- How do I check if a string is a number (float)?
- How to use a decimal range() step value?
- PHP – Floating Number Precision [duplicate]
- How to suppress scientific notation when printing float values?
- How to extract a floating number from a string [duplicate]
- Formatting floats without trailing zeros
- How to display a float with two decimal places?
- How do you round UP a number?
- Format / Suppress Scientific Notation from Pandas Aggregation Results
- How to truncate float values?
- How to avoid floating point errors? [duplicate]
- Convert floats to ints in Pandas?
- How to get a random number between a float range?
- round() doesn’t seem to be rounding properly
- How to print float to n decimal places including trailing 0s?
- How to get numbers after decimal point?
- How to round a floating point number up to a certain decimal place?
- Format floats with standard json module
- ValueError: could not convert string to float: id
- Range values to pseudocolor
- Convert floating point number to a certain precision, and then copy to string
- Easy pretty printing of floats?
- Testing floating point equality
- Convert Python strings into floats explicitly using the comma or the point as separators
- Binary representation of float in Python (bits not hex)
- Convert Bytes to Floating Point Numbers?
- Pandas read csv file with float values results in weird rounding and decimal digits
- Double precision floating values in Python?
- rounding errors in Python floor division
- Convert float to string in positional format (without scientific notation and false precision)
- What is the range of values a float can have in Python?
- Comparing floats in a pandas column
- Strange behaviour with floats and string conversion
- What class to use for money representation?
- Most Pythonic way to print *at most* some number of decimal places [duplicate]
- Print a float number in normal form, not exponential form / scientific notation [duplicate]
- How to manage division of huge numbers in Python?
- ‘is’ operator behaves unexpectedly with floats
- numpy float: 10x slower than builtin in arithmetic operations?
- Clarification on the Decimal type in Python