LPC Library Functions: to_int

NAME

to_int - convert a string, float, or buffer to an int

SYNOPSIS

int to_int( string | float | buffer x );

DESCRIPTION

If 'x' is a string, the to_int call returns the integer equivalent of the string's numeric value. If the string is not a numeric expression, to_int returns 0. Examples where 'x' is a string:

    > return to_int("dsajhkjhk");
    Returns: 0
    > return to_int("22/7");
    Returns: 22
    > return to_int("2312.9");
    Returns: 2312
    > return to_int("-324");
    Returns: -324
    > return to_int("+23");
    Returns: 23

If `x' is a float, the to_int() call returns the number of type `int' that is equivalent to `x' (with any decimal stripped off).

If `x' is a buffer, the call returns the integer (in network-byte-order) that is embedded in the buffer.

SEE ALSO

to_float(), read_buffer(), sprintf(), sscanf()

Page design by Frank Jacquette & Tim Hollebeek
Copyright (C) 1998 Tim Hollebeek & Frank Jacquette
Back to MudOS