Electron microscopy
 
Binary in DM
- Practical Electron Microscopy and Database -
- An Online Book -
Microanalysis | EM Book                                                                                   http://www.globalsino.com/EM/        


=================================================================================

 

Table 1134a. Binary in DM.

Binary (a) Convert a number to a binary string with a fixed length, (b) Convert a number to a binary string.

String Binary( Number n )

Returns the number as a binary string.
String Binary( Number n, Number length ) Returns the number as a binary string of the given length. Example

An example of logical OR operations is below (DM script):
         number MyA = 21967
         number MyB = 13

         Result( "\n\n")
         Result( "\n MyA (binary): " + binary( MyA, 16 ) )
         Result( "\n MyB (binary): " + binary( MyB, 16 ) )
         Result( "\n MyA | MyB ([OR]) : " + binary( MyA|MyB, 16 ))

The result of the program is shown in Table 1134b.  In this script, each digit performs a OR operation.    

Table 1134b. The results of DM script above (as 16-bit integer values). The rule of OR is on page1136.
MyA 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1
MyB 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1
MyA | MyB ([OR]) 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1

An example of logical AND operations is DM script. The result of the program is shown in Table 1134c.  In this script, each digit performs an AND operation.    

Table 1134c. The results of DM script above (as 16-bit integer values). The rule of AND is on page1136.
MyA 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1
MyB 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1
MyA & MyB ([AND]) 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1

As discussed on page1136, in DM and C++, logical XOR operation can be performed by "(a||b) &&!(a && b)"; however, in DM, XOR is simplified by "^" as shown a table on page1136 (e.g. DM script).

Table 1134d. Results of a DM script of a logical XOR operation by following the rule in a table on page1136.

MyA 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1
MyB 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1
MyA ^ MyB ([XOR]) 0 1 0 1 0 1 0 1 1 1 0 0 0 0 1 0

An example of logical NOT operations is DM script. In this script, each digit performs an NOT operation as well.    

 

 

 

 

 

=================================================================================