Thread: Validate a user input integer?

1. I really did, once again thank you.

2. Originally posted by alphaoide
No, problem. We enjoyed it. That's how we learn from one another. Hope you learn something, too.
Most definitely!

3. >didn't mean to start an entire war on whether or not to use int or string...
What fun would these forums be without well thought out arguments?

4. oops, one more question... is 112 the only 3 digit that works, and there must be some four digits that work too... Not that it really matters I suppose, but since the data in the arrays that will be storing the ISBNs are already ints and cannot be changed I am going to use an integer scheme as opposed to a string conversion, and since we really haven't learned anything about string to int conversion or vice versa I don't think that is what is being looked for. I appreciate all the help...

5. Actually, any combination of numbers works for the first four digits, right? You just have to take the sum of them modulus 9 and use that as the last digit. So I would guess there are 10 possible 2 digit ISBN's (00000, 00011, 00022, 00033, ... 00090), 90 possible 3 digits ISBN's (00101, 00112, 00123, ... 00202, ... 00990), and so on and so forth. That would make about 1000 valid ISBN's with at least one leading zero.

But of course you are right, it doesn't really matter. It only mattered in the case of Shakti's and Prelude's original code suggestions because they checked to make sure that there were no leading zeros in the 5 digit number. You don't have to include that check in your code (although I'd advise at least a check that the integer is not more than 5 digits).

6. i see. thanks.