|
|
1.1 root 1: .\" Copyright (c) 1983 Regents of the University of California.
2: .\" All rights reserved. The Berkeley software License Agreement
3: .\" specifies the terms and conditions for redistribution.
4: .\"
5: .\" @(#)bit.3f 6.4 (Berkeley) 4/30/86
6: .\"
7: .TH BIT 3F "April 30, 1986"
8: .UC 5
9: .SH NAME
10: bit \- and, or, xor, not, rshift, lshift bitwise functions
11: .SH SYNOPSIS
12: .B (intrinsic) function and (word1, word2)
13: .sp 1
14: .B (intrinsic) function or (word1, word2)
15: .sp 1
16: .B (intrinsic) function xor (word1, word2)
17: .sp 1
18: .B (intrinsic) function not (word)
19: .sp 1
20: .B (intrinsic) function rshift (word, nbits)
21: .sp 1
22: .B (intrinsic) function lshift (word, nbits)
23: .SH DESCRIPTION
24: These bitwise functions are built into the compiler and return
25: the data type of their argument(s).
26: Their arguments must be
27: .B integer
28: or
29: .B logical
30: values.
31: .PP
32: The bitwise combinatorial functions return the
33: bitwise ``and'' (\fBand\fR), ``or'' (\fBor\fR), or ``exclusive or'' (\fBxor\fR)
34: of two operands.
35: .B Not
36: returns the bitwise complement of its operand.
37: .PP
38: .IR Lshift ,
39: or
40: .I rshift
41: with a negative
42: .IR nbits ,
43: is a logical left shift with no end around carry.
44: .IR Rshift ,
45: or
46: .I lshift
47: with a negative
48: .IR nbits ,
49: is an arithmetic right shift with sign extension.
50: No test is made for a reasonable value of
51: .I nbits.
52: .PP
53: These functions may be used to create a variety of general routines, as in
54: the following statement function definitions:
55: .sp 1
56: .B integer bitset, bitclr, getbit, word, bitnum
57: .sp 1
58: .B bitset( word, bitnum ) = or(word,lshift(1,bitnum))
59: .br
60: .B bitclr( word, bitnum ) = and(word,not(lshift(1,bitnum)))
61: .br
62: .B getbit( word, bitnum ) = and(rshift(word,bitnum),1)
63: .SH FILES
64: These functions are generated in-line by the f77 compiler.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.