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

atoi

atoi( 
t_string [t]
) 
=> x_result / nil

Description

Converts a string into an integer. Returns nil if the given string does not denote an integer.

The atoi function calls the C library function strtol to convert a string into an integer. It returns nil if t_string does not represent an integer.

Arguments

t_string

A string.

t

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

Value Returned

x_result

The integer value represented by t_string.

nil

If t_string includes any non-numeric characters.

Examples

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

Related Topics

atof

Arithmetic Functions


Return to top
 ⠀
X