0

About the Type Casting problem in C++

The code is right logic but when it run, the output is false. Ex, enter number 5.56 and save into var 'a' t =(int)a =5 a = a-t => a=0.56. a*=10 =5.6 t = 5 a = a-t => a=0.6 a *=10 = 6 t = (int)a = 5(dont know why???) a = a-t => 1 if enter number ex 6 then it output right result. https://code.sololearn.com/cGPHYxzj6caq/?ref=app

20th Mar 2018, 6:45 AM
Nguyễn Bá Tùng
Nguyễn Bá Tùng - avatar
4 Respuestas
+ 8
https://code.sololearn.com/c3UAxnirjRw5/?ref=app cout is rounding. floating point math is fun
20th Mar 2018, 7:23 AM
jay
jay - avatar
+ 1
Dude, I'm seeing this question since last five minutes and still I'm unable to understand it....
20th Mar 2018, 6:54 AM
Akash papnai
Akash papnai - avatar
0
i run my code on app Mobile C on android.
20th Mar 2018, 7:02 AM
Nguyễn Bá Tùng
Nguyễn Bá Tùng - avatar