BSD 4_3 release
[unix-history] / usr / man / man3 / bit.3f
CommitLineData
4ec885fb
KM
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.\"
95f51977 5.\" @(#)bit.3f 6.4 (Berkeley) 4/30/86
4ec885fb 6.\"
95f51977 7.TH BIT 3F "April 30, 1986"
4ec885fb
KM
8.UC 5
9.SH NAME
10bit \- 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
24These bitwise functions are built into the compiler and return
25the data type of their argument(s).
9f694ead 26Their arguments must be
4ec885fb 27.B integer
9f694ead
RE
28or
29.B logical
30values.
4ec885fb
KM
31.PP
32The bitwise combinatorial functions return the
33bitwise ``and'' (\fBand\fR), ``or'' (\fBor\fR), or ``exclusive or'' (\fBxor\fR)
34of two operands.
35.B Not
36returns the bitwise complement of its operand.
37.PP
38.IR Lshift ,
39or
40.I rshift
41with a negative
42.IR nbits ,
43is a logical left shift with no end around carry.
44.IR Rshift ,
45or
46.I lshift
47with a negative
48.IR nbits ,
26b5771b 49is an arithmetic right shift with sign extension.
4ec885fb
KM
50No test is made for a reasonable value of
51.I nbits.
9f694ead
RE
52.PP
53These functions may be used to create a variety of general routines, as in
54the 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)
4ec885fb
KM
63.SH FILES
64These functions are generated in-line by the f77 compiler.