code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(42 lines)
1 '\" t
2 .\" Copyright (c) 2026 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Int.get_bit 3 2026-01-19 "Tomo man-pages"
6 .SH NAME
7 Int.get_bit \- check whether a bit is set
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Int.get_bit\ :\ func(i:\ Int,\ bit_index:\ Int\ ->\ Bool)
13 .fi
14 .SH DESCRIPTION
15 In the binary representation of an integer, check whether a given bit index is set to 1 or not.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx
23 l l l.
24 Name Type Description
25 i Int The integer whose bits are being inspected.
26 bit_index Int The index of the bit to check (1-indexed).
27 .TE
28 .SH RETURN
29 Whether or not the given bit index is set to 1 in the binary representation of the integer.
31 .SH NOTES
32 For fixed-size integers, the bit index must be between 1 and the number of bits in that integer (i.e. 1-64 for `Int64`). For `Int`, the bit index must be between 1 and `Int64.max`. Values outside this range will produce a runtime error.
34 .SH EXAMPLES
35 .EX
36 assert 6.get_bit(1) == no
37 assert 6.get_bit(2) == yes
38 assert 6.get_bit(3) == yes
39 assert 6.get_bit(4) == no
40 .EE
41 .SH SEE ALSO
42 .BR Tomo-Int (3)