+ 6

Are Float and int values are equal?

Float y=3.0 and Int x=3 are equal or not? in c++ eual then how?

16th Jun 2019, 2:51 PM
imtiaz Ahmad
imtiaz Ahmad - avatar
7 Réponses
+ 5
Should be able to compare with the == operator. Quick google search shows the int is converted to floating point, meaning that the numbers may not be perfectly equal when comparing them, but typically are.
16th Jun 2019, 2:55 PM
Jackson O’Donnell
+ 4
You can test it using ==
17th Jun 2019, 9:56 AM
Тимофей Козлов
Тимофей Козлов - avatar
+ 3
already deleted it was a mistake
16th Jun 2019, 3:18 PM
imtiaz Ahmad
imtiaz Ahmad - avatar
+ 2
No it's not in c++
17th Jun 2019, 6:28 PM
Akash Raj
Akash Raj - avatar
+ 2
one can say thats equal but not equal by general due to floating decimal values also in casting problems they are different
18th Jun 2019, 6:26 AM
Amandeep
Amandeep - avatar
0
Thanks all for valuable answers 👍
21st Jun 2019, 7:37 PM
imtiaz Ahmad
imtiaz Ahmad - avatar