[b90] isNumber() inconsistent

Confirmed bugs should get a single post here. Check the READ ME FIRST sticky thread for the format.

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice, MapTool BugReport Manager

Forum rules
Posts that do not conform to the READ ME FIRST sticky thread are subject to deletion.
Post Reply
dont_want_to_be_here
Kobold
Posts: 6
Joined: Wed Aug 13, 2014 5:25 pm

[b90] isNumber() inconsistent

Post by dont_want_to_be_here »

Discussion: http://forums.rptools.net/viewtopic.php?f=3&t=25308

isNumber returns true in the twenty instances of <decimal digit> <"d" or "f"> ("3d" or "5f" for example). It does not seem to respond to other hexidecimal numbers and these numbers are treated as strings by the default addition process.
The following should illustrate the issue by producing the output "1d1d".

Code: Select all

[h:test_string="1d"]
[r,if(isNumber(test_string)):test_string+test_string]
The following should allow for extensive testing of isNumber():

Code: Select all

[previous=0]
[h,while(1):abort(input("previous|"+previous+"|"+isNumber(previous)))]
It seems appropriate that isNumber() should reliably function according to decimal notation.

The following resulted in isNumber possessing the appropriate value.

Code: Select all

[H: value = "1d"]
[H: isNumber = 0]
[H, if(isNumber(value)), code: {
   [H: valCheck = replace(value,"^[0-9]","")]
   [H, if(value == valCheck): isNumber = 1]
};{}]

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: [b90] isNumber() inconsistent

Post by aliasmask »

Well, my example for you was only for positive integers >= 0. I would make a more precise regex check to include +/-#.## format.

dont_want_to_be_here
Kobold
Posts: 6
Joined: Wed Aug 13, 2014 5:25 pm

Re: [b90] isNumber() inconsistent

Post by dont_want_to_be_here »

Oh, wow, negatives didn't even occur to me : (

...

Yes, "-1d" is considered a number...
"-1b" is not.
So that makes, what, 38 instances now that it fails in.

Ugh, I just didn't think...

Post Reply

Return to “Bug Reports”