JCL Help:BitsToBooleans@Byte@TBooleanArray@Boolean

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Unpacks a set of bits into an array of booleans.


Pascal

 procedure BitsToBooleans(const Bits: Byte; var B: TBooleanArray; AllBits: Boolean = False); overload;
procedure BitsToBooleans(const Bits: Word; var B: TBooleanArray; AllBits: Boolean = False); overload;
procedure BitsToBooleans(const Bits: Integer; var B: TBooleanArray; AllBits: Boolean = False); overload;
procedure BitsToBooleans(const Bits: Int64; var B: TBooleanArray; AllBits: Boolean = False); overload;


Parameters

Parameters Description
const Bits: Byte The set of bits to unpack to an array of Booleans.
var B: TBooleanArray Array which receives the bits in Bits unpacked as Booleans.
AllBits: Boolean = False If set to True the number of elements in the resulting array equals the number of bits in the Bits parameter (ie 8 for Byte, 16 for Word, etc). If False the number of elements in the resulting array equals the position of the highest set bit.


Description

BitsToBooleans unpacks a set of bits into an array of Booleans. Each set bit in the Bits parameter results in a True valued Boolean while each cleared bit results in a False valued boolean. The resulting array has one element for each bit in the Bits parameter where bit 0 corresponds to B[0], bit 1 to B[1] etc. See also BooleansToBits for the inverse operation. If the AllBits parameter is True, the number of elements in the resulting array is the same as the number of bits in the Bits parameter, if set to False (the default) the resulting array has only as many elements as is required to hold the highest set bit position. For example, if Bits equals 2 than the highest set bit is bit 1 and the resulting array has only two elements: [True, False].


See Also

BooleansToBits


About

Unit

JclLogic


Donator

Robert Marquardt


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page