This is because the computer isn't able to exactly store 2.2 or 4.4 in a 
binary floating point with a limited number of bits.

This is similar to you trying to express 1/3 as a decimal and doing math 
with that (0.3333+0.3333+0.3333 = 0.9999 ≠ 1).

Remember computers aren't smarter than you, just a lot faster.

Please see: https://docs.python.org/3/tutorial/floatingpoint.html

On Sunday, March 8, 2020 at 2:26:50 PM UTC-6, SarahC5 GoRonix wrote:
>
> Hi, my name is *Veronica*, I am new to Python programming.
> I am using Spyder, and here is what is in my code.  It's giving
> me the *wrong output:*
>
> *EDITOR___*
> num1 = input("Enter a number: ")
> num2 = input("Enter another number: ")
> result = float(num1) + float(num2)
>
> print(result)
>
> *CONSOLE_____________*
> Enter a number: 4.4
>
> Enter another number: 2.2
> 6.6000000000000005
>
> *QUESTION________________*
> Why is this the output?  It's supposed to be 6.6
> Why is it adding those zeros and the five at the end?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/spyderlib/99031be9-8646-4f24-b782-03d6f4a01daa%40googlegroups.com.

Reply via email to