+ 2

I've been trying to understand what this code means. Please help out,

if (dollar == (int)dollar) {

16th Feb 2022, 7:26 PM
DevAbdul
DevAbdul - avatar
3 Antworten
+ 3
what is dollar type? where you saw it? May it's a double type. It's only true when value is like 5.0 then 5.0 == 5 But false for 5.2 since 5.2 != 5 edit: Try to check this, for both sample inputs 5.0 and 5.2 double dollar; cin>>dollar; if (dollar == (int)dollar) { cout<<"True"; } else cout<<"False";
16th Feb 2022, 7:32 PM
Jayakrishna 🇮🇳
+ 2
Full code will help more. But essentially here we are doing "comparison of same variable with Type casting" This will only resolve to true if the value for "dollar" variable is integer and doesn't contain any decimal values.
16th Feb 2022, 7:38 PM
Morpheus
Morpheus - avatar
0
Thanks, let me share the full code
16th Feb 2022, 7:59 PM
DevAbdul
DevAbdul - avatar