float problem

hello
Doedsany one now how can i write a if statement if i enter for example 10.00 i want to now if after the dott 00 or not
for example 10.55
10.00
the first no should return to me .55
and the second should return 00
Forgive me if I'm not understanding you right but you want an if statement that tells you if there's anything after the decimal and if so what numbers are after it?
Ok, calm down for a second, catch your breath, and then try to ask that again in an understandable fashion.
yes I want if statement that tells me if there is anything after the decimal and if so what numbers are after it
1
2
3
4
float intPart;
float fracPart;
fracPart = modf(10.5f, &intPart);
cout << intPart << " " <<fracPart;



10.0 0.5


modf is declared in cmath.

Know that floats are due to practical restrictions always imprecise, so the " after dot part" isn't necessarily what you'd expect it to be.
Last edited on
Thank you for your help
Topic archived. No new replies allowed.