Boolean values: Difference between revisions

m
Line 2,596:
Test an attribute for its presence (empty or not), or whether a node set is empty.
</xsl:if></lang>
 
=={{header|Z80 Assembly}}==
There are no official constants for True or False, however the common convention is to use 0 for false and nonzero for true. In reality, any mutually exclusive condition will work. True/False can be tested using a variety of instructions. The most common are <code>CP</code> and <code>BIT</code> but in certain cases it can be done faster using <code>AND</code> or even <code>RRCA</code>.
 
All of the following can be used to test if the rightmost bit of a byte is 1.
<lang Z80>BIT 0,A
jr nz,true
;;;;;;;;;;;;;;;;
AND 1
jr nz,true
;;;;;;;;;;;;;;;;
RRCA
jr c,true</lang>
 
Of these three methods, the last one is the fastest and takes the least amount of bytes to encode. However, it does destroy the variable, which may not be an option depending on what you need to do with that data later. <code>BIT</code> is slower than the rest but doesn't alter registers or memory, just the flags, which is sometimes exactly what you need.
 
 
 
=={{header|zkl}}==
1,489

edits