SourcePoint AMD Help

Table of Contents

strtol

Convert a string into an int4 variable.

Syntax

[result =] strtol(string-expr, base)

Where:

result

specifies a debug variable of type int4 to which the function return value is assigned. If result is not specified, the return value is displayed on the next line of the screen.

string-expr

specifies an nstring variable or a quoted string constant.

base

is the number base to be used in the conversion (2-36).

Discussion

The strtol command converts a string into an int4 variable. The strtol function expects the number to be converted to consist of:

  1. An optional plus or minus sign.

  2. A sequence of digits whose legal values are indicated by the base specified (e.g., a base of 16 indicates 0-9, a-f and A-F are legal values.)

  3. As a special case, if base is 16, then the string may begin with a 0x or 0X.

The conversion stops at the end of the string or after encountering an illegal character. If no conversion can be performed, then zero is returned.

Example 1

Command input:

strtol("1000", 16t)

Result:

00001000H

Example 2

Command input:

strtol("1000", 10t)

Result:

000003E8H

Example 3

Command input:

strtol("1000", 8t)

Result:

00000200H

Example 4

Command input:

strtol("1000", 2t)

Result:

00000008H

Related Topics: