ZTree.com  | ZEN  | About...  

 Index   Back

"isAnInteger" batch function flaw   [Q]

By: Nick Williams     West Sussex, England (forum time +5 hrs)  
Date: Sep 19,2017 at 11:02
In Response to: "isAnInteger" batch function flaw (John Gruener)

> The flaw is demonstrated by your "Test number 15". Note that while
> test 14 "007" is recognized as numeric, test 15 "009" is not. The
> reason is that any number with a leading zero is treated by SET /A as
> being octal. Therefore if it also contains the digits 8 or 9 it is
> considered invalid. And of course it follows that "070" will be
> interpreted as 56, and "0100" as 64.

Hi John,

Yes, you're absolutely right. In my hurry to supply a solution to Ryan's problem, I overlooked this. I had even included the "007" and "009" tests to remind myself !

To correct this, I will need to strip away any leading zeros and test against what's left.

But this raises the question as to whether I should consider a number that has leading zeros to be an integer, in the first place. I'm not sure.

I've always thought of numbers formatted with leading zeros as "numeric strings", commonly found as indexes to database tables.


Kind regards
Nick

222 views      
Thread locked
 

Messages in this Thread

 
94,476 Postings in 11,922 Threads, 348 registered users, 8 users online (0 registered, 8 guests)
Index | Admin contact |   Forum Time: Oct 17, 2019 - 4:20 pm EDT  |  Hits:28,768,928  (3,357 Today )
RSS Feed