summaryrefslogtreecommitdiff
path: root/reference/C/EXAMPLES/or.c
blob: 15418302abfea49dd6c7eca43c086cfcc31b14f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/****************************************************************************
 *
 * Purpose: To show the effect of a bitwise OR (|) by converting 
 * 	    an ASCII character to its graphic extension equivalent.
 * Author:  M.J. Leslie.
 * Date:    04-Mar-95
 *
 ****************************************************************************/

main()
{
					/* Hex 66 (f) looks like this in binary
					 *  
					 * 0110 0110
					 */
  unsigned char value='\x66';

					/* Hex 80 looks like this in binary
					 *
					 * 1000 0000
					 */

  printf("%2X %2X \n", value, (value | (unsigned char)'\x80'));

					/* A bitwise OR has the effect of 
					 * adding wanted bits.      
					 *
					 * 0110 0110 (66) OR
					 * 1000 0000 (80)
					 * --------- 
					 * 1110 0110 (E6)
					 */
}

/****************************************************************************
 *
 * Program results are:
 *
 *	66 E6
 *
 ****************************************************************************/