Manual Pages for UNIX Darwin command on man checkint
MyWebUniversity

Manual Pages for UNIX Darwin command on man checkint

CHECKINT32ADD(3) BSD Library Functions Manual CHECKINT32ADD(3)

NAME

cchheecckkiinntt3322aadddd, cchheecckkuuiinntt3322aadddd, cchheecckkiinntt6644aadddd, cchheecckkuuiinntt6644aadddd, cchheecckkiinntt3322ssuubb, cchheecckkuuiinntt3322ssuubb, cchheecckkiinntt6644ssuubb, cchheecckkuuiinntt6644ssuubb, cchheecckkiinntt3322mmuull, cchheecckkuuiinntt3322mmuull, cchheecckkiinntt6644mmuull, cchheecckkuuiinntt6644mmuull,

cchheecckkiinntt3322ddiivv, cchheecckkuuiinntt3322ddiivv, cchheecckkiinntt6644ddiivv, cchheecckkuuiinntt6644ddiivv, -

detect overflow in arithmetic

SYNOPSIS

##iinncclluuddee <>

int32t cchheecckkiinntt3322aadddd(int x, int y, int *err); uint32t cchheecckkuuiinntt3322aadddd(int x, int y, int *err); int64t cchheecckkiinntt6644aadddd(int x, int y, int *err); uint64t cchheecckkuuiinntt6644aadddd(int x, int y, int *err); int32t cchheecckkiinntt3322ssuubb(int x, int y, int *err); uint32t cchheecckkuuiinntt3322ssuubb(int x, int y, int *err); int64t cchheecckkiinntt6644ssuubb(int x, int y, int *err); uint64t cchheecckkuuiinntt6644ssuubb(int x, int y, int *err); int32t cchheecckkiinntt3322mmuull(int x, int y, int *err); uint32t cchheecckkuuiinntt3322mmuull(int x, int y, int *err); int64t cchheecckkiinntt6644mmuull(int x, int y, int *err); uint64t cchheecckkuuiinntt6644mmuull(int x, int y, int *err); int32t cchheecckkiinntt3322ddiivv(int x, int y, int *err); uint32t cchheecckkuuiinntt3322ddiivv(int x, int y, int *err); int64t cchheecckkiinntt6644ddiivv(int x, int y, int *err); uint64t cchheecckkuuiinntt6644ddiivv(int x, int y, int *err);

DESCRIPTION

The cchheecckk<><>(x, y, err) family of functions perform the specified arithmetic operation (addition, subtraction, multiplication, or division) with the left operand of x and right operand of y and return the arithmetic result with the specified type. Either operand x or y (or both) can be of any type that is compatible to

signed or unsigned 8-bit, 16-bit, 32-bit, or 64-bit integers.

The err argument is or'ed by flags in the function to indicate if an overflow has occurred. The possible flag values are:

CHECKINTNOERROR no overflow has occurred

CHECKINTOVERFLOWERROR overflow has occurred

CHECKINTTYPEERROR operand is of an incompatible type

The err argument is not cleared in calls to the

cchheecckk<><>(x, y, err) functions. Detected overflow per-

sists in the err argument until err is reset to CHECKINTNOERROR.

RETURN VALUES

If successful, the cchheecckk<><>() functions will return the arithmetic result of performing the operation with left operand x and right operand y (even when overflow error occurs).

If any other error occurs, the return value is -1 and the argument err

will be set to indicate the error. EEXXAAMMPPLLEESS /* Create a variable to store overflow flag */

int32t err = CHECKINTNOERROR;

/* Use checkint API to perform an arithmetic operation and

* store result in variable. */

int32t arithmeticresult = checkint32add(UINTMAX, 1, &err);

/* Check status of overflow flag */

if (err & CHECKINTOVERFLOWERROR) {

/* Perform overflow resolution code */ fprintf(stderr, "Overflow detected!\n"); } /* Check for type error */

else if (err & CHECKINTTYPEERROR) {

/* Deal with incompatible types error */ fprintf(stderr, "Incompatible types!\n"); } /* Reset overflow flag for next operation */

err = CHECKINTNOERROR;

EERRRROORRSS The cchheecckk<><>() functions may fail if:

[CHECKINTTYPEERROR] operand is of an incompatible type

HISTORY The cchheecckkiinntt() API was introduced in Mac OS X 10.5. BSD April 20, 2007 BSD




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™