Miscellaneous signed 32-bit functions, Integer conversions – Echelon Neuron C User Manual

Page 76

Advertising
background image

56

Functions

Miscellaneous Signed 32-bit Functions

Table 16 lists miscellaneous signed 32-bit functions.

Table 16. Signed 32-Bit Functions

Short
Name Function

sign

int s32_sign(const s32_type *arg);

Sign function, returns +1 if the argument is positive, 0 if the argument
is zero, and -1 if the argument is negative.

inc

void s32_inc(s32_type *arg);

Increments a signed 32-bit integer.

dec

void s32_dec(s32_type *arg);

Decrements a signed 32-bit integer.

mul2

void s32_mul2(s32_type *arg);

Multiplies a signed 32-bit integer by two.

div2

void s32_div2( s32_type *arg );

Divides a signed 32-bit integer by two.

rand

void s32_rand(s32_type *arg);

Returns a random integer uniformly distributed in the range

[-2,147,483,648 to +2,147,483,647].

Integer Conversions

Table 17 lists the integer conversion functions.

Table 17. Integer Conversions

Short

Name Function

to
slong

signed long s32_to_slong(const s32_type *arg);

Converts a signed 32-bit integer to a Neuron C signed long integer

(range -32,768 to +32,767). Overflow is ignored.

to
ulong

unsigned long s32_to_ulong(const s32_type *arg);

Converts a signed 32-bit integer to a Neuron C unsigned long integer
(range 0 to 65,535). Overflow is ignored.

from
slong

void s32_from_slong(signed long arg1, s32_type *arg2);

Converts a Neuron C signed long integer (range -32,768 to +32,767) to a
signed 32-bit integer.

Advertising