Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 float multiplication - unexpected output

I have a unexpected output on a simple multiplication:
While if I run an equivalent expression
Which is the right output. Is is also the case for other expressions like : 0.55*100 that gives: 55.00000000000001
Anybody knows what this is due to ?

Many thanks,

floating point is multiplication of two numbers, an integer times an exponent and therefore is a close approximation, not exact
Quote:Which is the right output.
Both are in their situation.
See this thread or this one
You need to learn more about floating point numbers.
Floating point numbers can't represent all decimal fractions.

import webbrowser + 0.2) + '.com')

If you need something, which does not have this problem: decimal fractions
Gribouillis and Larz60+ like this post
My code examples are always for Python >=3.6.0
Almost dead, but too lazy to die:
All humans together. We don't need politicians!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  ValueError: could not convert string to float: . BoaCoder3 3 58,266 Yesterday, 06:26 AM
Last Post: atlass218
  Comaparing Float Values of Dictionary Against A Float Value & Pick Matching Key firebird 2 142 Jul-25-2019, 11:32 PM
Last Post: scidam
  Unexpected Output using classes and inheritance langley 2 154 Jul-04-2019, 09:33 AM
Last Post: langley
  Tracing a multiplication table w/ Python trace() NationalRex22 0 128 Jun-11-2019, 03:31 AM
Last Post: NationalRex22
  ValueError: could not convert string to float michaelbs007 1 960 Jun-08-2019, 08:44 PM
Last Post: micseydel
  Help | float to Int in xlrd Vinci141 0 274 May-13-2019, 07:00 AM
Last Post: Vinci141
  Inclusive (closed) range with float numbers mapg 4 313 Apr-27-2019, 09:09 PM
Last Post: Gribouillis
  syntax error near unexpected token btom529 5 529 Apr-21-2019, 09:03 PM
Last Post: btom529
  Getting an unexpected generator object ? mcgrim 19 639 Mar-29-2019, 11:35 AM
Last Post: gontajones
  Dictionary adds an unexpected list erina 1 240 Mar-14-2019, 01:13 PM
Last Post: ichabod801

Forum Jump:

Users browsing this thread: 1 Guest(s)