Difference between revisions of "SHIP:Sail:atoi"

From Serious Documentation
Jump to: navigation, search
(Created page with "__NOTOC__ {{SailFuncTableStart|}}<onlyinclude> |{{SailFunc|atoi}}||{{DataType|Integer}}||style="text-align:center;"|v5.0.120||Parses a string to get an integer from it</onlyin...")
 
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
{{SailFuncTableStart|}}<onlyinclude>
 
{{SailFuncTableStart|}}<onlyinclude>
|{{SailFunc|atoi}}||{{DataType|Integer}}||style="text-align:center;"|v5.0.120||Parses a string to get an integer from it</onlyinclude>
+
|{{SailFunc|atoi}}||{{DataType|Integer}}||style="text-align:center;"|5.0.120||Parses a string to get an {{DataType|Integer}} from it</onlyinclude>
 
|}
 
|}
 
== See Also: ==
 
== See Also: ==
Line 24: Line 24:
 
|}
 
|}
 
== Detailed Description ==
 
== Detailed Description ==
The <code>{{SailFunc|atoi}}(string)</code> function returns the integer parsed value of a string which should contain the string version of an integer.
+
The <code>{{SailFunc|atoi}}(string)</code> function returns the {{DataType|Integer}} parsed value of a {{DataType|String}} which should contain the string version of an {{DataType|Integer}}.
 
== Examples ==
 
== Examples ==
 
{| class="wikitable" style="margin: 1em 1em;"  
 
{| class="wikitable" style="margin: 1em 1em;"  

Revision as of 15:48, 29 July 2014

Function Returns Introduced Description
atoi Integer 5.0.120 Parses a string to get an Integer from it

See Also:

Prototype

Integer atoi(String string);

Parameters/Return Value

Parameter Data Type Description
string String The string to parse
Return Integer the integer parsed value of the string

Detailed Description

The atoi(string) function returns the Integer parsed value of a String which should contain the string version of an Integer.

Examples

Example Result Notes
atoi("-5"); -5
atoi("+5"); +5
atoi("5.76"); +5 Parsing stops at the first non-number, in this case the '.'
atoi("57X"); +57 Parsing stops at the X
atoi("P57X"); 0 An error, parsing stops at the P*
  • try/catch is targeted for introduction in SHIP v5.1 to detect this condition.