Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected result
#2
The python float 0.1 is not exactly equal to the same mathematical number because computers store numbers in binary form and the real number 0.1 cannot be represented exactly in base 2 on 64 bits. This is not a limitation of python, it is a limitation of the widely adopted IEEE754 floating point format used by computers. The true value of 0.1 in your program is
>>> (0.1).as_integer_ratio()
(3602879701896397, 36028797018963968)
You can read this documentation page for more.
Reply


Messages In This Thread
Unexpected result - by eftimios - Dec-02-2018, 01:54 AM
RE: Unexpected result - by Gribouillis - Dec-02-2018, 07:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unexpected result linton 4 2,003 May-02-2020, 01:15 PM
Last Post: linton
  list sum gives unexpected result Nesso 0 1,700 Feb-04-2020, 08:31 AM
Last Post: Nesso
  Unexpected (?) result with regular expressions guraknugen 2 2,222 Jan-18-2020, 02:33 PM
Last Post: guraknugen
  Unexpected expected type error result MartinMaker 1 2,062 Feb-16-2019, 05:02 PM
Last Post: micseydel
  unexpected sub result after overloading operator jolinchewjb 1 2,285 Jan-24-2019, 08:23 AM
Last Post: buran
  Unexpected result in simple prime number example jackhj 2 3,017 Apr-20-2018, 01:48 AM
Last Post: jackhj
  Reversing word in strings yields unexpected result Dec 4 3,647 May-17-2017, 05:32 PM
Last Post: wavic
  datetime unexpected result PickyBiker 10 9,114 Dec-27-2016, 10:47 PM
Last Post: PickyBiker

Forum Jump:

User Panel Messages

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