Skip to content

Modern Math TryParseDouble

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Math Library › Math Library › TryParseDouble

TryParseDouble

Parses a whole string as a Double, returning an empty Optional if it is not one.

Syntax

TryParseDouble( s [, flags] )

Examples

#import "std/numeric"
using numeric

'' An Optional, so failure is absence rather than a zero that cannot be
'' told apart from a parsed "0"
var r = TryParseDouble( "1.5" )
print r.HasValue( )          '' true
print r.Value( )             '' 1.5

print TryParseDouble( "" ).HasValue( )        '' false
print TryParseDouble( "12abc" ).HasValue( )   '' false -- trailing junk

'' STRICT BY DEFAULT: no locale, no partial acceptance

Library: Math Library
Category: Math Library
Documented under: Nothing Becomes A Keyword

Clone this wiki locally