aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-Byte.get_bit.3
blob: ad92560e4b30612f022a0dc7abae22c9b519cf1d (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
42
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH Byte.get_bit 3 2025-11-29 "Tomo man-pages"
.SH NAME
Byte.get_bit \- check whether a bit is set
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Byte.get_bit\ :\ func(i:\ Byte,\ bit_index:\ Int\ ->\ Bool)
.fi
.SH DESCRIPTION
In the binary representation of a byte, check whether a given bit index is set to 1 or not.


.SH ARGUMENTS

.TS
allbox;
lb lb lbx
l l l.
Name	Type	Description
i	Byte	The byte whose bits are being inspected. 
bit_index	Int	The index of the bit to check (1-indexed, range 1-8). 
.TE
.SH RETURN
Whether or not the given bit index is set to 1 in the byte.

.SH NOTES
The bit index must be between 1-8 or a runtime error will be produced.

.SH EXAMPLES
.EX
assert Byte(6).get_bit(1) == no
assert Byte(6).get_bit(2) == yes
assert Byte(6).get_bit(3) == yes
assert Byte(6).get_bit(4) == no
.EE
.SH SEE ALSO
.BR Tomo-Byte (3)