Here we assumed that in the internal encoding of a string (that should be Unicode), 1 comes after 0, 2 after 1 and so on until 9.
Another way could be to get the C String from the NSString object, and then the parsing would be the same of the one we could do in standard C, so this path is not given.
Data:: Types exports functions that validate data types using both the above and other regular expressions.
A far better validator can be found on Stack Overflow[1] , that evaluate to numbers as well as certain elaborate numbers (large integers, rationals and complex numbers) whose literals parse to expressions that must be evaluated to yield numbers. (s: string) if (s == nil || Empty()) return false end if (! ('abc')puts '123- is not numeric' unless is_numeric2? If there a string of digits followed by an "e" or an "E" followed in turn by more digits, the numbers after the letter are treated as an exponent.
Testing strings that evaluate to function isnumeric(s:: T) isa(parse(s), Number)end tests = ["1", "-121", "one", "pi", "1 1", "Na N", "1234567890123456789", "1234567890123456789123456789", "1234567890123456789123456789.0", "1.3", "1.4e10", "Inf", "1//2", "1.0 1.0im"] for t in tests fl = isnumeric(t) ? s.starts With('-')) if s.contains('-') return false end end 0.upto(s.length()-1) do |x| c = At(x) if ((x == 0) && (c == '-'At(0))) # negative number elsif (c == '.'At(0)) if (s.index Of('.', x) -1) return false # more than one period end elsif (! ('123.1') puts 'nil is not numeric' unless is_numeric2? ('123-')puts '1.2.3 is not numeric' unless is_numeric2? Examples from command line: " one and a half": not numeric "1": numeric "1.5": numeric "1.5e 27": numeric " 1 ": numeric " 1.5 ": numeric " 1.5e 27 ": numeric "-one and a half": not numeric "-1": numeric "-1.5": numeric "-1.5E-27": numeric " - 1 ": numeric "- 1.5 ": numeric "- 1.5e-27 ": numeric " one and a half": not numeric "1": numeric "1.5": numeric "1.5E 27": numeric " 1 ": numeric " 1.5 ": numeric " 1.5e 27 ": numeric "Math Constants": not numeric "3.141592653589793": numeric "2.718281828459045": numeric "-3.141592653589793": numeric "-2.718281828459045": numeric "3.141592653589793": numeric "2.718281828459045": numeric "Numeric Constants": not numeric "Na N": not numeric "Infinity": not numeric "Infinity": not numeric The NSScanner class supports scanning of strings for various types.
The task doesn't define which strings are considered "numeric", so we do Integers and Doubles, which should catch the most common cases (including hexadecimal 0x notation): so read s:: Int (for instance) could be reliably used if string s passed these tests. The Lab VIEW version is shown on the top-right hand corner.
Haxe has a built-in function that will convert a string to an integer, so we can use that to determine if the string is numeric or not. You can download it, then drag-and-drop it onto the Lab VIEW block diagram from a file browser, and it will appear as runnable, editable code.
if ndex = 1 then Result = FALSE Exit function end if ndex = 1 case 48 to 57 '0 to 9 case else if instr(optchar,(mid$(s,i,1))) = 0 then Result = FALSE exit function end if end select next Result = TRUEEnd Function '============================================================'Begin'============================================================ showmessage (str$(is Numeric("-152.34","")))end print is Numeric("123") print is Numeric("1ab") ' ------------------------' Numeric Check' 0 = bad' 1 = good' ------------------------FUNCTION is Numeric(f$)is Numeric = 1f$ = trim$(f$)if left$(f$,1) = "-" or left$(f$,1) = " " then f$ = mid$(f$,2)for i = 1 to len(f$) d$ = mid$(f$,i,1) if d$ = "," then goto [nxt Digit] if d$ = "." then if dot$ = "." then is Numeric = 0 dot$ = "." goto [nxt Digit] end if if (d$ $ include "seed7_05.s7i"; include "scanstri.s7i"; const func boolean: is Numeric (in var string: stri) is func result var boolean: is Numeric is FALSE; local var string: number Stri is ""; begin number Stri := get Number(stri); is Numeric := stri = ""; end func; BEGIN BOOLEAN PROCEDURE ISNUMERIC(W); TEXT W; BEGIN BOOLEAN PROCEDURE MORE; MORE := W. LENGTH 0) AND THEN (NOT MORE) AND THEN DIGIT(LAST); END; REAL X; TEXT T; FOR X := 0, -3.1415, 2.768& 31, 5&10, .5, 5.&10 DO BEGIN OUTREAL(X, 10, 20); OUTIMAGE; END; OUTIMAGE; FOR T :- "0", "-3.1415", "2.768& 31", ".5", "5&22" DO BEGIN OUTTEXT(IF ISNUMERIC(T) THEN " NUMERIC " ELSE "NOT NUMERIC "); OUTCHAR('"'); OUTTEXT(T); OUTCHAR('"'); IF T = "0" THEN OUTCHAR(CHAR(9)); OUTCHAR(CHAR(9)); COMMENT PROBE ; X := T.
MORE; CHARACTER PROCEDURE NEXT; NEXT := IF MORE THEN W. GETREAL; OUTREAL(X, 10, 20); OUTIMAGE; END; OUTIMAGE; X := 5.&10; ! X := 5.; X := .5; FOR T :- "", "5.", "5&", "5& ", "5.&", "5.&-", "5.&10" DO BEGIN OUTTEXT(IF ISNUMERIC(T) THEN " NUMERIC " ELSE "NOT NUMERIC "); OUTCHAR('"'); OUTTEXT(T); OUTCHAR('"'); OUTIMAGE; END; END 0.000000000& 000 -3.141500000& 000 2.768000000& 031 5.000000000& 010 5.000000000&-001 5.100000000& 000 NUMERIC "0" 0.000000000& 000 NUMERIC "-3.1415" -3.141500000& 000 NUMERIC "2.768& 31" 2.768000000& 031 NUMERIC ".5" 5.000000000&-001 NUMERIC "5&22" 5.000000000& 022 NOT NUMERIC "" NOT NUMERIC "5." NOT NUMERIC "5&" NOT NUMERIC "5& " NOT NUMERIC "5.&" NOT NUMERIC "5.&-" NOT NUMERIC "5.&10" define('nchk(str)') :(nchk_end)nchk convert(str,'real') :s(return)f(freturn)nchk_end * # Wrapper for testing define('isnum(str)') :(isnum_end)isnum isnum = 'F'; isnum = nchk(str) 'T' isnum = isnum ': ' str :(return)isnum_end * # Test and display output = isnum('123') output = isnum('123.0') output = isnum('123.') output = isnum('-123') output = isnum('3.14159') output = isnum('1.2.3') output = isnum('abc') output = isnum('A440')end etc etc) Returns a flag of TRUE if character-string parameter represents a signed or unsigned integer. The success or failure is dependent on the source is valid in the current numeric base."is" : "is not" println(@sprintf(" 5s %s a direct numeric literal.", t, fl))end 1 is a direct numeric literal. Digit(c)) return false end end trueend puts '123 is numeric' if is_numeric2? ('1.2.3') # use a regular expression def is_numeric3? The scan Float method will return YES if the string is numeric, even if the number is actually too long to be contained by the precision of a float.If we want to scan by hand, we could use a function like the following, that checks if a number is an integer positive or negative number; spaces can appear at the beginning, but not after the number, and the ' ' or '-' can appear only attached to the number (" 123" returns YES, but " 123" returns NO).Returns true if it does, false otherwise % logical procedure is Numeric( string(32) value text ) ; begin logical ok; % the "number" cannot be blank % ok := ( text not = " " ); if ok then begin % there is at least one non-blank character % % must have either an integer or real/immaginary number % % integer: [ |-]digit-sequence % % real: [ |-][digit-sequence].digit-sequence['integer][L] % % or: [ |-]digit-sequence[.[digit-sequence'integer[L] % % imaginary: % % [ |-][digit-sequence].digit-sequence['integer][L]I% % or: [ |-]digit-sequence[.[digit-sequence]]'integer[L]I% % The "I" at the end of an imaginary number can appear % % before or after the "L" (which indicates a long number) % % the "I" and "L" can be in either case % procedure next Char ; char Pos := char Pos 1; logical procedure have( string(1) value ch ) ; ( char Pos 0 and text(max Char//1) = " " do max Char := max Char - 1; % skip leading spacesx % while have( " " ) do next Char; % skip optional sign % if have( " " ) or have( "-" ) then next Char; if have Digit then begin % have a digit sequence % had Digits := true; while have Digit do next Char end if_have_sign ; if have( "." ) then begin % real or imaginary number % next Char; is Real := true; had Digits := had Digits or have Digit; while have Digit do next Char end if_have_point ; % should have had some digits % ok := had Digits; if ok and have( "'" ) then begin % the number has an exponent % is Real := true; next Char; % skip optional sign % if have( " " ) or have( "-" ) then next Char; % must have a digit sequence % ok := have Digit; while have Digit do next Char; end if_ok_and_have_exponent ; % if it is a real number, there could be L/I suffixes % if ok and is Real then begin integer LCount, ICount; LCount := 0; ICount := 0; while have( "L" ) or have( "l" ) or have( "I" ) or have( "i" ) do begin if have( "L" ) or have( "l" ) then LCount := LCount 1 else ICount := ICount 1; next Char end while_have_L_or_I ; % there can be at most one L and at most 1 I % ok := ( LCount = max Char end if_ok ; ok end is Numeric ; % test the is Numeric procedure % procedure test Is Numeric( string(32) value n ; logical value expected Result ) ; begin logical actual Result; actual Result := is Numeric( n ); write( s_w := 0 , """", n, """ is " , if actual Result then "" else "not " , "numeric " , if actual Result = expected Result then "" else " NOT " , "as expected" ) end test Is Numeric ; test Is Numeric( "", false ); test Is Numeric( "b", false ); test Is Numeric( ".", false ); test Is Numeric( ".'3", false ); test Is Numeric( "3.'", false ); test Is Numeric( "0.0z44", false ); test Is Numeric( "-1IL", false ); test Is Numeric( "4.5'23ILL", false ); write( "---------" ); test Is Numeric( "-1", true ); test Is Numeric( " .345", true ); test Is Numeric( "4.5'23I", true ); test Is Numeric( "-5' 3i", true ); test Is Numeric( "-5'-3l", true ); test Is Numeric( " -.345LI", true ); end." " is not numeric as expected "b " is not numeric as expected ". The 'false' tells each method to return null if the string does not parse as a number of given type, otherwise, the 'from Str' method throws an exception. as double = 1234s" 1234e" is-numeric \ 1234e as float = 1234.s" $1234" is-numeric \ $1234 as integer = 4660 ( hex literal )s" 10" is-numeric \ 10 as integer = 10 ( binary literal )s" beef" is-numeric \ beef isn't numeric in base 10hexs" beef" is-numeric \ beef as integer = BEEFs" &1234" is-numeric \ &1234 as integer = 4D2 ( decimal literal ) Free BASIC has a built-in Val() function which converts numeric strings to doubles." is not numeric as expected ".'3 " is not numeric as expected "3.' " is not numeric as expected "0.0z44 " is not numeric as expected "-1IL " is not numeric as expected "4.5'23ILL " is not numeric as expected --------- "-1 " is numeric as expected " .345 " is numeric as expected "4.5'23I " is numeric as expected "-5' 3i " is numeric as expected "-5'-3l " is numeric as expected " -.345LI " is numeric as expected String numeric String = '123456'; String partly Numeric String = '123DMS'; String decimal String = '123.456'; System.debug(numeric Numeric()); // this will be true System.debug(partly Numeric Numeric()); // this will be false System.debug(decimal Numeric()); // this will be false System.debug(decimal String.remove('.')Numeric()); // this will be true Auto Hotkey has no explicitly defined variable types. cc -c c cc -o isnumber o -lbacon -lm Done, program 'isnumber' ready. However, it is not ideal for the present task since it will try to convert as much of the string as it can (so "123xyz" would convert to 123) and return 0 if a conversion on this basis is not possible (i.e. I've therefore written a custom function which recognizes signed numbers in bases from 2 to 16 (but only integral numbers for bases other than 10).Its semantics are somewhat cumbersome, so here's a "getnum" wrapper function for more convenient access.
||MORE; CHARACTER PROCEDURE NEXT; NEXT := IF MORE THEN W. GETREAL; OUTREAL(X, 10, 20); OUTIMAGE; END; OUTIMAGE; X := 5.&10; ! X := 5.; X := .5; FOR T :- "", "5.", "5&", "5& ", "5.&", "5.&-", "5.&10" DO BEGIN OUTTEXT(IF ISNUMERIC(T) THEN " NUMERIC " ELSE "NOT NUMERIC "); OUTCHAR('"'); OUTTEXT(T); OUTCHAR('"'); OUTIMAGE; END; END 0.000000000& 000 -3.141500000& 000 2.768000000& 031 5.000000000& 010 5.000000000&-001 5.100000000& 000 NUMERIC "0" 0.000000000& 000 NUMERIC "-3.1415" -3.141500000& 000 NUMERIC "2.768& 31" 2.768000000& 031 NUMERIC ".5" 5.000000000&-001 NUMERIC "5&22" 5.000000000& 022 NOT NUMERIC "" NOT NUMERIC "5." NOT NUMERIC "5&" NOT NUMERIC "5& " NOT NUMERIC "5.&" NOT NUMERIC "5.&-" NOT NUMERIC "5.&10" define('nchk(str)') :(nchk_end)nchk convert(str,'real') :s(return)f(freturn)nchk_end * # Wrapper for testing define('isnum(str)') :(isnum_end)isnum isnum = 'F'; isnum = nchk(str) 'T' isnum = isnum ': ' str :(return)isnum_end * # Test and display output = isnum('123') output = isnum('123.0') output = isnum('123.') output = isnum('-123') output = isnum('3.14159') output = isnum('1.2.3') output = isnum('abc') output = isnum('A440')end etc etc) Returns a flag of TRUE if character-string parameter represents a signed or unsigned integer. The success or failure is dependent on the source is valid in the current numeric base.
"is" : "is not" println(@sprintf(" 5s %s a direct numeric literal.", t, fl))end 1 is a direct numeric literal. Digit(c)) return false end end trueend puts '123 is numeric' if is_numeric2? ('1.2.3') # use a regular expression def is_numeric3? The scan Float method will return YES if the string is numeric, even if the number is actually too long to be contained by the precision of a float.
If we want to scan by hand, we could use a function like the following, that checks if a number is an integer positive or negative number; spaces can appear at the beginning, but not after the number, and the ' ' or '-' can appear only attached to the number (" 123" returns YES, but " 123" returns NO).
Returns true if it does, false otherwise % logical procedure is Numeric( string(32) value text ) ; begin logical ok; % the "number" cannot be blank % ok := ( text not = " " ); if ok then begin % there is at least one non-blank character % % must have either an integer or real/immaginary number % % integer: [ |-]digit-sequence % % real: [ |-][digit-sequence].digit-sequence['integer][L] % % or: [ |-]digit-sequence[.[digit-sequence]]'integer[L] % % imaginary: % % [ |-][digit-sequence].digit-sequence['integer][L]I% % or: [ |-]digit-sequence[.[digit-sequence]]'integer[L]I% % The "I" at the end of an imaginary number can appear % % before or after the "L" (which indicates a long number) % % the "I" and "L" can be in either case % procedure next Char ; char Pos := char Pos 1; logical procedure have( string(1) value ch ) ; ( char Pos 0 and text(max Char//1) = " " do max Char := max Char - 1; % skip leading spacesx % while have( " " ) do next Char; % skip optional sign % if have( " " ) or have( "-" ) then next Char; if have Digit then begin % have a digit sequence % had Digits := true; while have Digit do next Char end if_have_sign ; if have( "." ) then begin % real or imaginary number % next Char; is Real := true; had Digits := had Digits or have Digit; while have Digit do next Char end if_have_point ; % should have had some digits % ok := had Digits; if ok and have( "'" ) then begin % the number has an exponent % is Real := true; next Char; % skip optional sign % if have( " " ) or have( "-" ) then next Char; % must have a digit sequence % ok := have Digit; while have Digit do next Char; end if_ok_and_have_exponent ; % if it is a real number, there could be L/I suffixes % if ok and is Real then begin integer LCount, ICount; LCount := 0; ICount := 0; while have( "L" ) or have( "l" ) or have( "I" ) or have( "i" ) do begin if have( "L" ) or have( "l" ) then LCount := LCount 1 else ICount := ICount 1; next Char end while_have_L_or_I ; % there can be at most one L and at most 1 I % ok := ( LCount = max Char end if_ok ; ok end is Numeric ; % test the is Numeric procedure % procedure test Is Numeric( string(32) value n ; logical value expected Result ) ; begin logical actual Result; actual Result := is Numeric( n ); write( s_w := 0 , """", n, """ is " , if actual Result then "" else "not " , "numeric " , if actual Result = expected Result then "" else " NOT " , "as expected" ) end test Is Numeric ; test Is Numeric( "", false ); test Is Numeric( "b", false ); test Is Numeric( ".", false ); test Is Numeric( ".'3", false ); test Is Numeric( "3.'", false ); test Is Numeric( "0.0z44", false ); test Is Numeric( "-1IL", false ); test Is Numeric( "4.5'23ILL", false ); write( "---------" ); test Is Numeric( "-1", true ); test Is Numeric( " .345", true ); test Is Numeric( "4.5'23I", true ); test Is Numeric( "-5' 3i", true ); test Is Numeric( "-5'-3l", true ); test Is Numeric( " -.345LI", true ); end." " is not numeric as expected "b " is not numeric as expected ". The 'false' tells each method to return null if the string does not parse as a number of given type, otherwise, the 'from Str' method throws an exception. as double = 1234s" 1234e" is-numeric \ 1234e as float = 1234.s" $1234" is-numeric \ $1234 as integer = 4660 ( hex literal )s" 10" is-numeric \ 10 as integer = 10 ( binary literal )s" beef" is-numeric \ beef isn't numeric in base 10hexs" beef" is-numeric \ beef as integer = BEEFs" &1234" is-numeric \ &1234 as integer = 4D2 ( decimal literal ) Free BASIC has a built-in Val() function which converts numeric strings to doubles.
" is not numeric as expected ".'3 " is not numeric as expected "3.' " is not numeric as expected "0.0z44 " is not numeric as expected "-1IL " is not numeric as expected "4.5'23ILL " is not numeric as expected --------- "-1 " is numeric as expected " .345 " is numeric as expected "4.5'23I " is numeric as expected "-5' 3i " is numeric as expected "-5'-3l " is numeric as expected " -.345LI " is numeric as expected String numeric String = '123456'; String partly Numeric String = '123DMS'; String decimal String = '123.456'; System.debug(numeric Numeric()); // this will be true System.debug(partly Numeric Numeric()); // this will be false System.debug(decimal Numeric()); // this will be false System.debug(decimal String.remove('.')Numeric()); // this will be true Auto Hotkey has no explicitly defined variable types. cc -c c cc -o isnumber o -lbacon -lm Done, program 'isnumber' ready. However, it is not ideal for the present task since it will try to convert as much of the string as it can (so "123xyz" would convert to 123) and return 0 if a conversion on this basis is not possible (i.e. I've therefore written a custom function which recognizes signed numbers in bases from 2 to 16 (but only integral numbers for bases other than 10).
Its semantics are somewhat cumbersome, so here's a "getnum" wrapper function for more convenient access.
||MORE; CHARACTER PROCEDURE NEXT; NEXT := IF MORE THEN W. GETREAL; OUTREAL(X, 10, 20); OUTIMAGE; END; OUTIMAGE; X := 5.&10; ! X := 5.; X := .5; FOR T :- "", "5.", "5&", "5& ", "5.&", "5.&-", "5.&10" DO BEGIN OUTTEXT(IF ISNUMERIC(T) THEN " NUMERIC " ELSE "NOT NUMERIC "); OUTCHAR('"'); OUTTEXT(T); OUTCHAR('"'); OUTIMAGE; END; END 0.000000000& 000 -3.141500000& 000 2.768000000& 031 5.000000000& 010 5.000000000&-001 5.100000000& 000 NUMERIC "0" 0.000000000& 000 NUMERIC "-3.1415" -3.141500000& 000 NUMERIC "2.768& 31" 2.768000000& 031 NUMERIC ".5" 5.000000000&-001 NUMERIC "5&22" 5.000000000& 022 NOT NUMERIC "" NOT NUMERIC "5." NOT NUMERIC "5&" NOT NUMERIC "5& " NOT NUMERIC "5.&" NOT NUMERIC "5.&-" NOT NUMERIC "5.&10" define('nchk(str)') :(nchk_end)nchk convert(str,'real') :s(return)f(freturn)nchk_end * # Wrapper for testing define('isnum(str)') :(isnum_end)isnum isnum = 'F'; isnum = nchk(str) 'T' isnum = isnum ': ' str :(return)isnum_end * # Test and display output = isnum('123') output = isnum('123.0') output = isnum('123.') output = isnum('-123') output = isnum('3.14159') output = isnum('1.2.3') output = isnum('abc') output = isnum('A440')end etc etc) Returns a flag of TRUE if character-string parameter represents a signed or unsigned integer. The success or failure is dependent on the source is valid in the current numeric base.
"is" : "is not" println(@sprintf(" 5s %s a direct numeric literal.", t, fl))end 1 is a direct numeric literal. Digit(c)) return false end end trueend puts '123 is numeric' if is_numeric2? ('1.2.3') # use a regular expression def is_numeric3? The scan Float method will return YES if the string is numeric, even if the number is actually too long to be contained by the precision of a float.
If we want to scan by hand, we could use a function like the following, that checks if a number is an integer positive or negative number; spaces can appear at the beginning, but not after the number, and the ' ' or '-' can appear only attached to the number (" 123" returns YES, but " 123" returns NO).
Returns true if it does, false otherwise % logical procedure is Numeric( string(32) value text ) ; begin logical ok; % the "number" cannot be blank % ok := ( text not = " " ); if ok then begin % there is at least one non-blank character % % must have either an integer or real/immaginary number % % integer: [ |-]digit-sequence % % real: [ |-][digit-sequence].digit-sequence['integer][L] % % or: [ |-]digit-sequence[.[digit-sequence]]'integer[L] % % imaginary: % % [ |-][digit-sequence].digit-sequence['integer][L]I% % or: [ |-]digit-sequence[.[digit-sequence]]'integer[L]I% % The "I" at the end of an imaginary number can appear % % before or after the "L" (which indicates a long number) % % the "I" and "L" can be in either case % procedure next Char ; char Pos := char Pos 1; logical procedure have( string(1) value ch ) ; ( char Pos 0 and text(max Char//1) = " " do max Char := max Char - 1; % skip leading spacesx % while have( " " ) do next Char; % skip optional sign % if have( " " ) or have( "-" ) then next Char; if have Digit then begin % have a digit sequence % had Digits := true; while have Digit do next Char end if_have_sign ; if have( "." ) then begin % real or imaginary number % next Char; is Real := true; had Digits := had Digits or have Digit; while have Digit do next Char end if_have_point ; % should have had some digits % ok := had Digits; if ok and have( "'" ) then begin % the number has an exponent % is Real := true; next Char; % skip optional sign % if have( " " ) or have( "-" ) then next Char; % must have a digit sequence % ok := have Digit; while have Digit do next Char; end if_ok_and_have_exponent ; % if it is a real number, there could be L/I suffixes % if ok and is Real then begin integer LCount, ICount; LCount := 0; ICount := 0; while have( "L" ) or have( "l" ) or have( "I" ) or have( "i" ) do begin if have( "L" ) or have( "l" ) then LCount := LCount 1 else ICount := ICount 1; next Char end while_have_L_or_I ; % there can be at most one L and at most 1 I % ok := ( LCount = max Char end if_ok ; ok end is Numeric ; % test the is Numeric procedure % procedure test Is Numeric( string(32) value n ; logical value expected Result ) ; begin logical actual Result; actual Result := is Numeric( n ); write( s_w := 0 , """", n, """ is " , if actual Result then "" else "not " , "numeric " , if actual Result = expected Result then "" else " NOT " , "as expected" ) end test Is Numeric ; test Is Numeric( "", false ); test Is Numeric( "b", false ); test Is Numeric( ".", false ); test Is Numeric( ".'3", false ); test Is Numeric( "3.'", false ); test Is Numeric( "0.0z44", false ); test Is Numeric( "-1IL", false ); test Is Numeric( "4.5'23ILL", false ); write( "---------" ); test Is Numeric( "-1", true ); test Is Numeric( " .345", true ); test Is Numeric( "4.5'23I", true ); test Is Numeric( "-5' 3i", true ); test Is Numeric( "-5'-3l", true ); test Is Numeric( " -.345LI", true ); end." " is not numeric as expected "b " is not numeric as expected ". The 'false' tells each method to return null if the string does not parse as a number of given type, otherwise, the 'from Str' method throws an exception. as double = 1234s" 1234e" is-numeric \ 1234e as float = 1234.s" $1234" is-numeric \ $1234 as integer = 4660 ( hex literal )s" 10" is-numeric \ 10 as integer = 10 ( binary literal )s" beef" is-numeric \ beef isn't numeric in base 10hexs" beef" is-numeric \ beef as integer = BEEFs" &1234" is-numeric \ &1234 as integer = 4D2 ( decimal literal ) Free BASIC has a built-in Val() function which converts numeric strings to doubles.
]]