# does not equal

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 07-28-2002
Klinerr1
does not equal
i want to doa thing like if (input != anumber)

but what woudl i put meaning not a number 1-9999999999999999999999999999999999999999999999 (any number)
• 07-28-2002
fletch
if ((input >= min) && (input <= max))

• 07-28-2002
Klinerr1
that will work but not exactly
• 07-28-2002
Klinerr1
well i need it to say if it doesnt equal a number
• 07-28-2002
fletch
Quote:

well i need it to say if it doesnt equal a number
Quote:

if (input != anumber)
I'm not picking up what you're putting down. What exactly are you asking?
• 07-28-2002
Okiesmokie
i think he means if they enter a character instead of a number
• 07-28-2002
fletch
Quote:

i think he means if they enter a character instead of a number
Are you asking... If I ask for a numerical input, how do I verify it's a number and not a letter?
• 07-28-2002
golfinguy4
I think he's asking how to represent java's NaN (not a number). Kinda like 7/0 or something like that.
• 07-28-2002
Klinerr1
i want it to see if it does not equal a number meaning not a number is a-z !@@##%%^%%^*(#\$@# that kind of stuff. a numbe being like math. you know
• 07-28-2002
fletch
You're asking...If I ask for input, how do I verify it's a letter and not a number?

if ( (((int)intput) < 176) && (((int)input) > 185) )

where input is a char. That's a lot of parenthesis.

There might be a better way though.
• 07-28-2002
Klinerr1
that didnt work it if u accidnelty input a character it goes all crazy
• 07-28-2002
gapostolis
Is this you're looking for?

----------
code :
----------

#include <iostream.h>

typedef unsigned long int lint;

int main()
{
lint input;
lint num = 100;
lint max = 4294967295;

cout<<"Give a number : "<<endl;
cin>>input;

if ( ((input >= 1) && (input <= max)) && (input != num) )
cout<<"Ok";
else
cout<<"Not Ok";

return 0;
}
• 07-28-2002
moonwalker
hmm
i dont know if there's a better way of doing this, but..

here's how i would do it :-

get the input to an array...

check out through each element of the array and see
if there's atleast 'one' element that is other than
0,1,2,3,4,5,6,7,8,9 (and) '.' (if you're also considering
floating points) .. and '-' ... and so on... (note that
- and . can't repeat in the array)

(i've done this before... let me check if i still have it )
meanwhile, try it with these clues..
• 07-28-2002
Klinerr1
if you stillahve puuullllleaaaaaase send it!
• 07-28-2002
Okiesmokie
Searching around on MSDN i found this function:

Code:

```#include <ctype.h> //.. if( isdigit(input) != 0 ) {         // input is a digit } else {         // input is a character }```
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last