diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-06-26 13:06:47 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-06-26 13:06:47 -0400 |
| commit | 8a4d5dc57b14e7c947c25970bb4d4f4ef91450f4 (patch) | |
| tree | e36042760c7c22d5a08777939484c06830d73404 /man | |
| parent | c2653404944dbd5a6f737877f0bad6fd1de018f1 (diff) | |
Add get_bit() method for Ints and Bytes
Diffstat (limited to 'man')
| -rw-r--r-- | man/man3/tomo-Byte.get_bit.3 | 44 | ||||
| -rw-r--r-- | man/man3/tomo-Int.get_bit.3 | 44 |
2 files changed, 88 insertions, 0 deletions
diff --git a/man/man3/tomo-Byte.get_bit.3 b/man/man3/tomo-Byte.get_bit.3 new file mode 100644 index 00000000..85d6c2ae --- /dev/null +++ b/man/man3/tomo-Byte.get_bit.3 @@ -0,0 +1,44 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Byte.get_bit 3 2025-06-26 "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 lb +l l l l. +Name Type Description Default +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 +>> Byte(6).get_bit(1) += no +>> Byte(6).get_bit(2) += yes +>> Byte(6).get_bit(3) += yes +>> Byte(6).get_bit(4) += no +.EE diff --git a/man/man3/tomo-Int.get_bit.3 b/man/man3/tomo-Int.get_bit.3 new file mode 100644 index 00000000..e0b98909 --- /dev/null +++ b/man/man3/tomo-Int.get_bit.3 @@ -0,0 +1,44 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.get_bit 3 2025-06-25 "Tomo man-pages" +.SH NAME +Int.get_bit \- check whether a bit is set +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI Int.get_bit\ :\ func(i:\ Int,\ bit_index:\ Int\ ->\ Bool) +.fi +.SH DESCRIPTION +In the binary representation of an integer, check whether a given bit index is set to 1 or not. + + +.SH ARGUMENTS + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +i Int The integer whose bits are being inspected. - +bit_index Int The index of the bit to check (1-indexed). - +.TE +.SH RETURN +Whether or not the given bit index is set to 1 in the binary representation of the integer. + +.SH NOTES +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. + +.SH EXAMPLES +.EX +>> (6).get_bit(1) += no +>> (6).get_bit(2) += yes +>> (6).get_bit(3) += yes +>> (6).get_bit(4) += no +.EE |
