Difference between revisions of "SetBit"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Odessa
(0-indexed, and don't use for bit > 29. source jaam.)
imported>Hemingway
m
 
Line 30: Line 30:
*SetBit considers the first bit be numbered, <b>0</b>, and the final bit to be <b>31</b>; however, it should not be used to change bits greater than 29 to avoid sign and float conversion issues.
*SetBit considers the first bit be numbered, <b>0</b>, and the final bit to be <b>31</b>; however, it should not be used to change bits greater than 29 to avoid sign and float conversion issues.
==See Also==
==See Also==
*[[GetBit]]
*[[ClearBit]]
*[[ClearBit]]
*[[SetEquipmentSlotsMask]]
*[[SetEquipmentSlotsMask]]

Latest revision as of 13:21, 6 October 2015

< [[::Category:Functions|Category:Functions]]

A function added by the New Vegas Script Extender.

Description

Returns the specified int with the specified bit set to 1, or optionally 0 (cleared). This function is useful for manipulating bitmasks.

Syntax

[help]
(int) SetBit Target:int BitToSet:int NewBitValue:bool

Example

int a
set a to 11		; bits 0, 1, 3 set
set a to SetBit a, 2	; sets bit 2 (value 4)
; a is now 15
set a to SetBit a, 1, 0	; would set bit 1 (value 2), but the third parameter is 0 so instead it clears the bit
; a is now 13

Notes

  • SetBit considers the first bit be numbered, 0, and the final bit to be 31; however, it should not be used to change bits greater than 29 to avoid sign and float conversion issues.

See Also