From QB64 Wiki
Revision as of 14:07, 5 March 2021 by Odin (talk | contribs) (Text replacement - "==Availability==" to "{{PageAvailability}}")
Jump to navigation Jump to search

The _TOGGLEBIT function is used to toggle a specified bit of a numerical value.


result = _TOGGLEBIT(numericalVariable, numericalValue)


  • numericalVariable is the variable to toggle the bit of and can be of the following types: _BYTE, INTEGER, LONG, or _INTEGER64.
  • Integer values can be signed or _UNSIGNED.
  • numericalValue the number of the bit to be set.


  • Can be used to manually manipulate individual bits of an integer value by toggling their state.
  • A bit set to 1 is changed to 0 and a bit set to 0 is changed to 1.
  • Bits start at 0 (so a _BYTE has bits 0 to 7, INTEGER 0 to 15, and so on)


  • Version 1.4 and up.


Example 1:

A~%% = 0 '_UNSIGNED _BYTE PRINT A~%% A~%% = _TOGGLEBIT(A~%%,4) 'toggle the fourth bit of A~%% PRINT A~%% A~%% = _TOGGLEBIT(A~%%,4) 'toggle the fourth bit of A~%% PRINT A~%%

0 16 0

See also

Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page