Skip to content

bitset

general · scripts/general/bitset.m

: c = bitset (a, n)
: c = bitset (a, n, assumedtype)
: c = bitset (a, n, val)
: c = bitset (a, n, val, assumedtype)

Set (or clear) bit n of the integers in a.

Bit 1 is the least significant bit. Without val the bit is set; otherwise it is set when val is nonzero and cleared when it is zero. A character/string third argument is treated as assumedtype (with an implied set). Double a is treated as "uint64" unless assumedtype names another integer class; the result for a double input is always double.