Determine if a string is numeric: Difference between revisions

no edit summary
No edit summary
Line 4,828:
PRINT "It is numeric."
End If</lang>
 
=={{header|Vlang}}==
<lang vlang>import strconv
 
fn is_numeric(s string) bool {
strconv.atof64(s) or {
return false
}
return true
}
 
fn main() {
println("Are these strings numeric?")
strings := ["1", "3.14", "-100", "1e2", "NaN", "rose", "0xff", "0b110"]
for s in strings {
println(" ${s:4} -> ${is_numeric(s)}")
}
}</lang>
 
{{out}}
<pre>
Are these strings numeric?
1 -> true
3.14 -> true
-100 -> true
1e2 -> true
NaN -> false
rose -> false
0xff -> true
0b110 -> true
</pre>
 
=={{header|Wren}}==
338

edits