Hi,
how could i check is a number an int or a float?
radiat 0 Newbie Poster
Recommended Answers
Jump to PostSince you created it, shouldn't you already know?
int x; // this one is an int float y; // this one is a float
Jump to Postanswer = x/y;
That's going to return an integer anyway - int/int gives an int, no matter what the values are.
Anyway, you already decided on a way, remember?if ((x % y) == 0 ) //if the numbers divide evenly the answer is …
Jump to Posti don't know what you mean by this?
Perhaps he means this:
bool isInt; if ((x % y) == 0 ) //if the numbers divide evenly the answer is an integer isInt = true; answer_int = divide_int(x,y); else isInt = false; answer_float = divide_float(x,y); //if not …
All 10 Replies
Moschops 683 Practically a Master Poster Featured Poster
radiat 0 Newbie Poster
The_Purple_Mask 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
radiat 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
radiat 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
radiat 0 Newbie Poster
dragon8001 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.