JCL Help:ToggleBit@Byte@TBitRange

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Toggles a bit in an integer-type value.


Pascal

 function ToggleBit(const Value: Byte; const Bit: TBitRange): Byte; overload;
function ToggleBit(const Value: Shortint; const Bit: TBitRange): Shortint; overload;
function ToggleBit(const Value: Smallint; const Bit: TBitRange): Smallint; overload;
function ToggleBit(const Value: Word; const Bit: TBitRange): Word; overload;
function ToggleBit(const Value: Cardinal; const Bit: TBitRange): Cardinal; overload;
function ToggleBit(const Value: Integer; const Bit: TBitRange): Integer; overload;
function ToggleBit(const Value: Int64; const Bit: TBitRange): Int64; overload;


Parameters

Parameters Description
const Value: Byte The integer-typed variable for which to toggle a bit.
const Bit: TBitRange The 0 based bit position of the bit to toggle. This is a modulo N bit position where N is the number of bits in the Value parameter. For example, if Value is a Byte then Bit position is interpreted as Bit mod 8.


Return Value

Copy of Value with the bit at position Bit toggled.


Description

ToggleBit toggles the specified bit position of the supplied integer typed variable. In other words, if the bit at the specified position is 0, then it is set to 1, if it's 1 then it is set to 0.


See Also

TestBit ClearBit TestBits SetBit


About

Unit

JclLogic


Donator

Marcel van Brakel


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