std-bittoggle


Synopsis

(std-bittoggle <val> <flag>)

Description

std-bittoggle inverses the bit of all set bits of val on the flag.

It used for example in changing OSMODE settings, to turn on or off some bits in a flag at once. A flag 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 usesbit values too, such as the initget flag: 1,2,4,8,16,32,64,128. A bitvalue of 41 is (1+8+32)

Example

(std-bittoggle 41 129)  => 168 (= 128+8+32)
41  = 1+8+32
129 = 1+128

Arguments

val: An integer number representing a bitvalue or a sum of bitvalues.

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

Return Value

A integer number, the new flag.

Side Effects

None.

Module

(std-require 'STDMATH)

Defined in STDMATH