### Revision history for KeyPgBitset

##### Additions:

print bin(bitset(&b10001,2))

%%10101

5

%%10101

5

##### Deletions:

##### Additions:

For the ##//bit_number//## values outside the valid range, the results of this macro are undefined.

##### Additions:

To set a specified bit in a variable, the following assignment can be used: ##//variable// = **Bitset**( //variable//, //bit_number// )##

##### Additions:

Gets the value with a specified bit set, from a copied integer.

##### Deletions:

##### Additions:

Gets a value from an integer copied with a specified bit set.

##### Deletions:

##### Additions:

The valid range of values for ##//bit_number//## depends on the size, in bits, of `##[[KeyPgTypeof|Typeof]](//value//)##`, which is `##0##` (from the lowest bit) through `##[[KeyPgSizeof|Sizeof]](//value//) * 8 - 1##` (up to the highest bit). See [[TblVarTypes|Standard Datatype Limits]] for a table of the standard datatypes and their sizes.

##### Deletions:

No Differences

##### Additions:

[[KeyPgPpdefine|#define]] **Bitset**( //value//, //bit_number// ) ((//value//) [[KeyPgOpOr|or]] ([[KeyPgCast|Cast]]([[KeyPgTypeof|TypeOf]](//Value//), 1) [[KeyPgOpShiftLeft|shl]] (//bit_number//)))

This macro expands to a copy of the integer ##//value//## with the specified ##//bit_number//## set (to //on//, or `##1##`). Behaves as `##//value// [[KeyPgOpOr|Or]] (1 [[KeyPgOpShiftLeft|Shl]] //bit_number//)##`.

The valid range of values for ##//bit_number//## depends on the size, in bits, of `##[[KeyPgTypeof|Typeof]](//value//)##`, which is `##0##` through `##[[KeyPgSizeof|Sizeof]](//value//) * 8 - 1##`. See [[TblVarTypes|Standard Datatype Limits]] for a table of the standard datatypes and their sizes.

- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Bitset""**##.

- ##[[KeyPgBit|Bit]]##

- ##[[KeyPgBitreset|Bitreset]]##

This macro expands to a copy of the integer ##//value//## with the specified ##//bit_number//## set (to //on//, or `##1##`). Behaves as `##//value// [[KeyPgOpOr|Or]] (1 [[KeyPgOpShiftLeft|Shl]] //bit_number//)##`.

The valid range of values for ##//bit_number//## depends on the size, in bits, of `##[[KeyPgTypeof|Typeof]](//value//)##`, which is `##0##` through `##[[KeyPgSizeof|Sizeof]](//value//) * 8 - 1##`. See [[TblVarTypes|Standard Datatype Limits]] for a table of the standard datatypes and their sizes.

- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Bitset""**##.

- ##[[KeyPgBit|Bit]]##

- ##[[KeyPgBitreset|Bitreset]]##

##### Deletions:

This macro expands to a copy of the integer ##//value//## with the specified ##//bit_number//## set (to //on//, or `##1##`). Behaves as `##//value// [[KeyPgOpOr Or]] (1 [[KeyPgOpShiftLeft Shl]] //bit_number//)##`.

The valid range of values for ##//bit_number//## depends on the size, in bits, of `##[[KeyPgTypeof Typeof]](//value//)##`, which is `##0##` through `##[[KeyPgSizeof Sizeof]](//value//) * 8 - 1##`. See [[TblVarTypes Standard Datatype Limits]] for a table of the standard datatypes and their sizes.

- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Bitset""**##.

- ##[[KeyPgBit Bit]]##

- ##[[KeyPgBitreset Bitreset]]##

##### Additions:

- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Bitset""**##.

##### Deletions:

#### Revision [14265]

Edited on 2009-08-29 21:51:17 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]##### Additions:

- New to ""FreeBASIC"".

##### Deletions:

##### Additions:

//result// = **Bitset**( //value//, //bit_number// )