std-bitsetp


Synopsis

(std-bitsetp <val> <flag>)

Description

std-bitsetp returns T if all the 1 bits in bitvalue val are set in flag, NIL otherwise.

It used to check settings in a flag, which is used to store independent logical values in a single integer number. It uses bit values and not bit positions because the online help for flags uses bit values too, such as the initget flag: 1,2,4,8,16,32,64,128

Same as (/= (rem flag val) 0) or (= (logand val flag) val)

Example

(std-bitsetp 4 12)  => T

because the third bit (4 = 0*2^0 + 0*2^1 + 1*2^2) is also set in 12
4:	[0100]
12:	[1100]

Open point:
logbitp ("logical bit predicate") is the equivalent name in Common Lisp, but bitsetp ("is the bit set?") is easier to remember and fits better to setbit,bitdel, bitlist and bittoggle, all functions dealing with flags.

Arguments

val: An integer number representing a bitvalue.

flag: A integer number representing a flag, a logical sum of bitvalues.

Return Value

T or NIL.

Side Effects

None.

Module

(std-require 'STDMATH)

Defined in STDMATH