ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


functions:parseint

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
functions:parseint [2017/04/17 15:31] korshunfunctions:parseint [2017/04/17 15:38] (current) korshun
Line 13: Line 13:
   * PARSENUMBER_BADFORMAT -- the number failed to parse. r2 is unchanged.   * PARSENUMBER_BADFORMAT -- the number failed to parse. r2 is unchanged.
  
 +<note tip>For simple parsing use [[atoi]].</note>
 +
 +===== Examples =====
 +<code>
 +ParseInt("123", 0);
 +r1 -> PARSENUMBER_SUCCESS
 +r2 -> 123
 +
 +ParseInt("0", 0);
 +r1 = PARSENUMBER_SUCCESS
 +r2 -> 0
 +
 +ParseInt("999999999999", 0)
 +r1 -> PARSENUMBER_OVERFLOW
 +r2 -> 2147483647
 +
 +ParseInt("-99999999999", 0)
 +r1 -> PARSENUMBER_OVERFLOW
 +r2 -> -2147483647
 +
 +ParseInt("not a number", 0)
 +r1 -> PARSENUMBER_BADFORMAT
 +
 +ParseInt("1.3", 0) -> 0
 +r1 -> PARSENUMBER_BADFORMAT
 +
 +ParseInt("0xff", 0) // Hexadecimal prefix
 +r1 -> PARSENUMBER_SUCCESS
 +r2 -> 255
 +
 +ParseInt("ff", 16) // Parse in hexadecimal
 +r1 -> PARSENUMBER_SUCCESS
 +r2 -> 255
 +
 +ParseInt("0xff", 16) // 0x causes syntax error
 +r1 -> PARSENUMBER_BADFORMAT
 +
 +ParseInt
 +</code>
functions/parseint.1492432267.txt.gz · Last modified: 2017/04/17 15:31 by korshun