Skip to content

Modern Math TryParseSingle

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

Home › Math Library › Math Library › TryParseSingle

TryParseSingle

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

Syntax

TryParseSingle( s [, flags] )

Examples

#import "std/numeric"
using numeric

var r = TryParseSingle( "1.5" )
print r.HasValue( )          '' true
print r.Value( )             '' 1.5

'' A magnitude too large for a SINGLE is still accepted -- it becomes
'' an infinity rather than being rejected, so check IsFinite when that
'' matters
print TryParseSingle( "1e300" ).HasValue( )   '' true

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

Clone this wiki locally