carta
ggidev-sign_3(3)

ggidev-sign_33

Triple-int properties

Usage

int sign_3(unsigned x [3] );

int bits_3(unsigned x [3] );

int eq0_3(unsigned x [3] );

int gt0_3(unsigned x [3] );

int ge0_3(unsigned x [3] );

int lt0_3(unsigned x [3] );

int le0_3(unsigned x [3] );

Overview

sign_3 checks the sign of x.

bits_3 counts the number of significant bits of x. I.e. leading zeros in a positive value and leading ones in a negative value are not counted.

eq0_3, gt0_3, ge0_3, lt0_3 and le0_3 tests the relation between x and zero. eq0_3 tests if x is equal to zero, gt0_3 if x is greater than zero, ge0_3 if x is greater than or equal to zero, lt0_3 if x is less than zero and last but not least le0_3 tests if x is less than or equal to zero.

Return value

sign_3 returns -1 for negative values, 0 for zero values and 1 for positive values.

bits_3 returns 0 for x equal to 0 or -1, 1 for x equal to 1 and -2, 2 for x equal to 2, 3, -3 and -4 etc.

eq0_3, gt0_3, ge0_3, lt0_3 and le0_3 all returns non-zero if the relation is true, and zero otherwise.

Examples

Some triple-int tests:

unsigned x[3];
assign_int_3(x, 5);
ASSERT(sign_3(x) == 1);
ASSERT(bits_3(x) == 3);
ASSERT(!eq0_3(x));
ASSERT(gt0_3(x));
ASSERT(ge0_3(x));
ASSERT(!lt0_3(x));
ASSERT(!le0_3(x));

History

  • Debian 6.0 (Squeeze) to Debian 5.0 (Lenny): the text shown here
  • Debian 4.0 (Etch)

From libggi2-dev 1:2.2.2-5 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.