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

Thread locked

Messages in this Thread

94,638 Postings in 11,936 Threads, 348 registered users, 11 users online (0 registered, 11 guests)
Index | Admin contact |   Forum Time: Dec 7, 2019 - 1:54 pm EST  |  Hits:29,377,018  (2,195 Today )
RSS Feed