Python Forum
Not rounding to desired decimal places?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not rounding to desired decimal places?
#3
(Mar-05-2021, 11:04 AM)Gribouillis Wrote: Floating numbers are stored in binary format by the computer. Real numbers such as 0.1 that have a finite number of decimal digits may have an infinite number of binary digits. It means that they are not stored exactly and a rounding error may become visible in arithmetic operations. For example
>>> 0.10047 - (0.09047 + 0.01)
1.3877787807814457e-17
>>> 0.09047 * 100
9.046999999999999
See this manual page. Note that this limitation is not due to the Python language.


That was really helpful Gribouillis. Thanks!
Reply


Messages In This Thread
Not rounding to desired decimal places? - by pprod - Mar-05-2021, 10:29 AM
RE: Not rounding to desired decimal places? - by pprod - Mar-05-2021, 11:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  need help rounding joseph202020 7 1,338 Feb-21-2023, 08:13 PM
Last Post: joseph202020
  Json filter is not capturing desired key/element mrapple2020 1 1,144 Nov-24-2022, 09:22 AM
Last Post: ibreeden
  from numpy array to csv - rounding SchroedingersLion 6 2,205 Nov-14-2022, 09:09 PM
Last Post: deanhystad
  how can I display only desired items? 3lnyn0 5 2,053 Dec-25-2021, 06:49 PM
Last Post: menator01
  Calculate the Euler Number with more decimal places Pedroski55 10 4,534 Oct-31-2021, 04:45 AM
Last Post: Pedroski55
  Random data generation sum to 1 by rounding juniorcoder 9 3,455 Oct-20-2021, 03:36 PM
Last Post: deanhystad
  Rounding issue kmll 1 1,424 Oct-08-2021, 10:35 AM
Last Post: Yoriz
  ERROR: importing desired module mbgamer28 0 1,689 Apr-05-2021, 07:46 PM
Last Post: mbgamer28
  Decimal Rounding error project_science 4 2,773 Jan-06-2021, 03:14 PM
Last Post: project_science
  Can I format decimal places by column with a dictionary? Mark17 2 2,581 Dec-28-2020, 10:13 PM
Last Post: Mark17

Forum Jump:

User Panel Messages

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