You are on page 1of 1

Built-In Functions

Function:

Tests the specified bit (0-7,0-15 or 0-31) in the given


variable. The least significant bit is 0. This function is
much more efficient than, but otherwise the same as: ((var &
(1<<bit)) != 0)

Availability:

All devices

Requires

Nothing

Examples:

if( bit_test(x,3) || !bit_test (x,1) ){


//either bit 3 is 1 or bit 1 is 0
}

if(data!=0)
for(i=31;!bit_test(data, i);i--) ;
// i now has the most significant bit in data
// that is set to a 1

Example Files:

ex_patg.c

Also See:

bit_clear(), bit_set()

BSEARCH()
Syntax:

ip = bsearch (&key, base, num, width, compare)

Parameters:

key: Object to search for


base: Pointer to array of search data
num: Number of elements in search data
width: Width of elements in search data
compare: Function that compares two elements in search
data

Returns:

bsearch returns a pointer to an occurrence of key in the array


pointed to by base. If key is not found, the function returns
NULL. If the array is not in order or contains duplicate records
with identical keys, the result is unpredictable.

Function:

Performs a binary search of a sorted array

Availability:

All devices

93

You might also like