ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


functions:atoi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
functions:atoi [2017/03/21 15:59] korshunfunctions:atoi [2017/04/17 15:33] korshun
Line 4: Line 4:
  
 ===== Description ===== ===== Description =====
-Returns s converted to int. On error, returns 0.+Returns s parsed as a decimal integer. If s cannot be parsed as an integer, returns 0. 
 + 
 +If s is too big or too small to fit into int, returns [[constants:INT_MAX]] with the sign of the input. 
 + 
 +Supports signs and [[:Number prefixes]]. 
 + 
 +<note tip>To parse fixed-point numbers, use [[atof]]. For more flexibility in parsing and error handlinguse [[ParseInt]].</note> 
 + 
 +===== Examples ===== 
 +<code> 
 +atoi("123") -> 123 
 +atoi("0") -> 0 
 +atoi("999999999999") -> 2147483647 // Too big 
 +atoi("-99999999999") -> -2147483647 // Too small 
 +atoi("not a number") -> 0 // Error 
 +atoi("1.3") -> 0 // Error 
 +atoi("0xff") -> 255 // Hexadecimal prefix 
 +</code> 
  
-See [[:Number parsing]] for features and examples. 
functions/atoi.txt · Last modified: 2017/04/17 15:33 by korshun