|
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
|
02-24-2009 17:41
I've seen a lot of great functions around for evaluating numbers in all various permutations, but I've been happy using the following one for simple needs with whole numbers, as I don't have to sacrifice half the script memory just to validate a number. How do I make it work with negative whole numbers, though? integer StringIsNumeric(string source) { integer rval = 0; if ( ( (float)source >= 1.175494351E-3  || (source == "0" ) ) rval = 1; return rval; }
_____________________
Thread attempting to compile a list of which animations are freebies, and which are not: http://forums.secondlife.com/showthread.php?t=265609
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
02-24-2009 18:23
EDIT: OK now I remember default { state_entry() { llListen(77, "","",""); } listen(integer channel, string name, key id, string message) { float test = (float)message; test = test * 2 / 2; if(test != 0) llOwnerSay("is a number"); else llOwnerSay("is not a number"); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-24-2009 18:45
lower your test limit to the max range for negative floats
EDIT: all solutions are going to have caveats, except testing for characters including hex and scientific variations. doubling is good but will fail on anything that breaks the range limits. divide then multiply may work better (FURTHER EDIT: or not since you may run into the precision limit with that method... always caveats)
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
|
02-25-2009 07:12
Many thanks all.
_____________________
Thread attempting to compile a list of which animations are freebies, and which are not: http://forums.secondlife.com/showthread.php?t=265609
|