Determine if a string is numeric: Difference between revisions
no edit summary
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
No edit summary |
||
Line 2,306:
123xyz (base 10) => false
xyz (base 10) => false
</pre>
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">include "NSLog.incl"
local fn StringIsNumeric( string as CFStringRef ) as BOOL
BOOL flag = NO
ScannerRef scanner = fn ScannerWithString( string )
if ( fn ScannerScanFloat( scanner, NULL ) )
flag = fn ScannerIsAtEnd( scanner )
end if
end fn = flag
NSLog(@"%d",fn StringIsNumeric( @"1.23" ))
NSLog(@"%d",fn StringIsNumeric( @"-123.4e5" ))
NSLog(@"%d",fn StringIsNumeric( @"alpha" ))
HandleEvents</syntaxhighlight>
{{out}}
<pre>
1
1
0
</pre>
|