The number I'm looking for is valid when it's positive, and nine digits. I used ( (value >= 100000000) && (value <= 999999999) ) first, which worked okay, but did not account for leading zeroes. How do I validate a nine digit number, using only math and no functions, with possible leading zeroes?
idlackage
0
Light Poster
Recommended Answers
Jump to PostThe number I'm looking for is valid when it's positive, and nine digits. I used ( (value >= 100000000) && (value <= 999999999) ) first, which worked okay, but did not account for leading zeroes. How do I validate a nine digit number, using only math and no functions, with …
Jump to PostStart with strlen(), before you convert it.
Jump to PostSalem, he says he wants to use no functions. Could just count them up, but then that's the same thing as going through it with the index iterator.
All 12 Replies
Adak
419
Nearly a Posting Virtuoso
Salem
5,138
Posting Sage
Adak
419
Nearly a Posting Virtuoso
jephthah
1,888
Posting Maven
Salem
5,138
Posting Sage
jephthah
1,888
Posting Maven
idlackage
0
Light Poster
jephthah
1,888
Posting Maven
idlackage
0
Light Poster
jephthah
1,888
Posting Maven
idlackage
0
Light Poster
jephthah
1,888
Posting Maven
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.