Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

atof

atof( 
t_string [t]
) 
=> f_result / nil

Description

Converts a string into a floating-point number. Returns nil if the given string does not denote a number.

The atof function calls the C library function strtod to convert a string into a floating-point number. It returns nil if t_string does not represent a number.

Arguments

t_string

A string.

t

If t_string includes any non-numerical characters, this argument enforces that nil is returned.

Value Returned

f_result

The floating-point value represented by t_string.

nil

If t_string includes any non-numerical characters.

Examples

atof("123")              
=> 123.0
atof("abc")              
=> nil
atof("123.456")          
=> 123.456
atof("123abc")           
=> 123.0
atof("12.01.01")         
=> 12.01
atof("12.01.01" t)       
=> nil

Related Topics

atoi

Arithmetic Functions


Return to top
 ⠀
X