isNumber(-) give true ??

Here's where to post questions and suggestions regarding forum use. Requests for new forum topics should be posted here as well.

isNumber(-) give true ??

Postby jguillou » Tue Apr 10, 2018 2:51 pm

With 4.8b31 put IsNumber("-") or isNumber(-) give true ? With 4.7 isNumber(-) give false. Why ?
jguillou
 
Posts: 44
Joined: Fri Jul 31, 2009 7:26 am

Re: isNumber(-) give true ??

Postby codegreen » Tue Apr 10, 2018 7:09 pm

That's a bug.

The SC interpreter's numerical code was all rewritten in 4.8 to use the Cocoa NSDecimal API, which greatly extends its numerical precision and range.

Unbeknownst to me though (and AFAICT not mentioned in the docs) apparently when you pass a string consisting solely of a lone plus or minus sign (as opposed to say an X or some other non-numerical character) to NSDecimal's initWithString method, rather than getting back the usual NaN (i.e., Not a Number) instead you get 0 (zero).

Live and learn...

Thanks!
-Mark
codegreen
 
Posts: 1556
Joined: Mon Jul 14, 2008 11:03 pm


Return to Site News, Questions, and Feedback

Who is online

Users browsing this forum: No registered users and 1 guest

cron