Determine if a string is numeric: Difference between revisions
Content deleted Content added
Zig version added |
Add SmallBASIC |
||
Line 1,383: | Line 1,383: | ||
You entered a number.</pre> |
You entered a number.</pre> |
||
NB: While "99, rue de Rivoli" contains a number it is not a number entirely. The Val(v$) in this case would have stopped after it converted the "99" portion of the input, which when converted back to a string and compared to the original input would not result in an equality. 9E4 the program reads as an exponential value. |
NB: While "99, rue de Rivoli" contains a number it is not a number entirely. The Val(v$) in this case would have stopped after it converted the "99" portion of the input, which when converted back to a string and compared to the original input would not result in an equality. 9E4 the program reads as an exponential value. |
||
==={{header|SmallBASIC}}=== |
|||
y = isnumber(s) returns true if s is a number or can be converted to a number. |
|||
<syntaxhighlight lang="qbasic"> |
|||
a = 1.2345 |
|||
b = "abc" |
|||
c = "-1.2345" |
|||
print isnumber(a) |
|||
print isnumber(b) |
|||
print isnumber(c) |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
1 |
|||
0 |
|||
1 |
|||
</pre> |
|||
=={{header|Batch File}}== |
=={{header|Batch File}}== |