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

Table of contents


NAME

is_neg_safe, is_neg_safel, is_neg_safell - test for safe integer negation

SYNOPSIS

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

#include <mathcw.h>

extern int is_neg_safe (int a);

extern int is_neg_safel (long int a);

extern int is_neg_safell (long long int a);

DESCRIPTION

Determine whether the integer argument can be negated 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.


RETURN VALUES

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

ERRORS

None.

SEE ALSO

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