第七章 操作位和位串(三)
操作位串
要创建新的位串,请使用 $bit 函数将所需位设置为 1:
kill bitstring
set $bit(bitstring, 3) = 1
set $bit(bitstring, 6) = 1
set $bit(bitstring, 11) = 1
使用 $bit 将现有位串中的位设置为 1:
set $bit(bitstring, 5) = 1
使用 $bit 将现有位串中的位设置为 0:
set $bit(bitstring, 5) = 0
由于位串中的第一位是位 1,因此尝试设置位 0 会返回错误: