Difference between revisions of "Bit"
From SimsWiki
MogHughson (Talk | contribs) |
MogHughson (Talk | contribs) (→Example) |
||
Line 7: | Line 7: | ||
Bit number 3 when set gives a value 0x04. | Bit number 3 when set gives a value 0x04. | ||
− | Turning on bits number 1 and | + | Turning on bits number 1 and 3 gives a value 0x05. |
Turning on any bit twice doesn't change the value. The switch is on, it can't be on any more. | Turning on any bit twice doesn't change the value. The switch is on, it can't be on any more. |
Latest revision as of 13:38, 22 April 2011
[edit] Overview
Lots of things in SimAntics are represented by bit flags. If you are a programmer you may already be familiar with adding up bit numbers, if you are not, this page is for you! Think of bits like switches. If switch number 1 (bit 1) is turned on then a certain thing happens. Several switches can be on at once whilst others are off.
[edit] Example
Bit number 1 when set gives a value 0x01.
Bit number 2 when set gives a value 0x02.
Bit number 3 when set gives a value 0x04.
Turning on bits number 1 and 3 gives a value 0x05.
Turning on any bit twice doesn't change the value. The switch is on, it can't be on any more.