IS_ABS_SAFE 3CW "21 March 2008" "mathcw-1.00"

Table of contents


NAME

is_abs_safe, is_abs_safel, is_abs_safell - test for safe integer absolute value

SYNOPSIS

cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ]

#include <mathcw.h>

extern int is_abs_safe (int a);

extern int is_abs_safel (long int a);

extern int is_abs_safell (long long int a);

DESCRIPTION

Determine whether the absolute value of the integer argument can be computed safely without overflow.

In the common two's-complement arithmetic system, the most negative integer has no positive counterpart, and negating it produces the same negative integer, with the unexpected result that its absolute value is negative, rather than positive.


RETURN VALUES

Return 1 if the operation is safe, and 0 otherwise.

ERRORS

None.

SEE ALSO

is_add_safe(3CW), is_div_safe(3CW), is_mul_safe(3CW), is_neg_safe(3CW), is_rem_safe(3CW), is_sub_safe(3CW).