0

Wrong output problem :(

Can anyone tell me plz why there is lots of 0s followed by 2 next to the output ? Where did they really come from ? https://code.sololearn.com/cNJ4H0Q0nW0T/?ref=app

12th Aug 2020, 6:01 PM
Mdy
8 odpowiedzi
+ 3
Maybe cause first assigned value of X is double not float so final value will be also double that's why there r so many 0s .Hope this helps 🙇🏻‍♂️
12th Aug 2020, 6:37 PM
Prasad Bankar
Prasad Bankar - avatar
+ 3
Mdy Try small even numbers! This generally doesn't create a big problem! If yes then you can ask me anytime! I ll love to help you!
12th Aug 2020, 7:12 PM
Namit Jain
Namit Jain - avatar
+ 2
This is because it becomes hard for the system to calculate in decimals because it uses binary! So the answer becomes a bit wrong
12th Aug 2020, 6:06 PM
Namit Jain
Namit Jain - avatar
+ 2
Blue☘食亜査 python is not type strict! That minor difference is coming due to the reason I have told Mdy if you try smaller numbers: print(6+2.345) => 7.345 (Caution: this difference becomes bigger when you use odd numbers)
12th Aug 2020, 6:43 PM
Namit Jain
Namit Jain - avatar
+ 2
Maybe u r saying correct 😁
12th Aug 2020, 6:59 PM
Prasad Bankar
Prasad Bankar - avatar
+ 1
I tried using double n then removed it and it worked for me 🤷🏻‍♂️
12th Aug 2020, 6:44 PM
Prasad Bankar
Prasad Bankar - avatar
+ 1
Thanks Doesn't this difference make any problem in more complicated codes ? I tried smaller numbers , too and there was still some difference but less than the bigger numbers
12th Aug 2020, 7:07 PM
Mdy
+ 1
Yeah I tried and there were no difference this time . Thanks for your help !
12th Aug 2020, 7:17 PM
Mdy