1
0
Fork 0
cl-sites/guile.html_node/rnrs-arithmetic-bitwise.html
2024-12-17 12:49:28 +01:00

160 lines
12 KiB
HTML

<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This manual documents Guile version 3.0.10.
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
Inc.
Copyright (C) 2021 Maxime Devos
Copyright (C) 2024 Tomas Volf
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
copy of the license is included in the section entitled "GNU Free
Documentation License." -->
<title>rnrs arithmetic bitwise (Guile Reference Manual)</title>
<meta name="description" content="rnrs arithmetic bitwise (Guile Reference Manual)">
<meta name="keywords" content="rnrs arithmetic bitwise (Guile Reference Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content=".texi2any-real">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="R6RS-Standard-Libraries.html" rel="up" title="R6RS Standard Libraries">
<link href="rnrs-syntax_002dcase.html" rel="next" title="rnrs syntax-case">
<link href="rnrs-arithmetic-flonums.html" rel="prev" title="rnrs arithmetic flonums">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
</head>
<body lang="en">
<div class="subsubsection-level-extent" id="rnrs-arithmetic-bitwise">
<div class="nav-panel">
<p>
Next: <a href="rnrs-syntax_002dcase.html" accesskey="n" rel="next">rnrs syntax-case</a>, Previous: <a href="rnrs-arithmetic-flonums.html" accesskey="p" rel="prev">rnrs arithmetic flonums</a>, Up: <a href="R6RS-Standard-Libraries.html" accesskey="u" rel="up">R6RS Standard Libraries</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsubsection" id="rnrs-arithmetic-bitwise-1"><span>7.6.2.23 rnrs arithmetic bitwise<a class="copiable-link" href="#rnrs-arithmetic-bitwise-1"> &para;</a></span></h4>
<p>The <code class="code">(rnrs arithmetic bitwise (6))</code> library provides procedures for
performing bitwise arithmetic operations on the two&rsquo;s complement
representations of fixnums.
</p>
<p>This library and the procedures it exports share functionality with
SRFI-60, which provides support for bitwise manipulation of integers
(see <a class="pxref" href="SRFI_002d60.html">SRFI-60 - Integers as Bits</a>).
</p>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dnot-1"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-not</strong> <var class="def-var-arguments">ei</var><a class="copiable-link" href="#index-bitwise_002dnot-1"> &para;</a></span></dt>
<dt class="deffnx def-cmd-deffn" id="index-bitwise_002dand-1"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-and</strong> <var class="def-var-arguments">ei1 ...</var><a class="copiable-link" href="#index-bitwise_002dand-1"> &para;</a></span></dt>
<dt class="deffnx def-cmd-deffn" id="index-bitwise_002dior-1"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-ior</strong> <var class="def-var-arguments">ei1 ...</var><a class="copiable-link" href="#index-bitwise_002dior-1"> &para;</a></span></dt>
<dt class="deffnx def-cmd-deffn" id="index-bitwise_002dxor-1"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-xor</strong> <var class="def-var-arguments">ei1 ...</var><a class="copiable-link" href="#index-bitwise_002dxor-1"> &para;</a></span></dt>
<dd><p>These procedures are identical to the <code class="code">lognot</code>, <code class="code">logand</code>,
<code class="code">logior</code>, and <code class="code">logxor</code> procedures provided by Guile&rsquo;s core
library. See <a class="xref" href="Bitwise-Operations.html">Bitwise Operations</a>, for documentation.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dif-1"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-if</strong> <var class="def-var-arguments">ei1 ei2 ei3</var><a class="copiable-link" href="#index-bitwise_002dif-1"> &para;</a></span></dt>
<dd><p>Returns the bitwise &ldquo;if&rdquo; of its arguments. The bit at position
<code class="code">i</code> in the return value will be the <code class="code">i</code>th bit from <var class="var">ei2</var>
if the <code class="code">i</code>th bit of <var class="var">ei1</var> is 1, the <code class="code">i</code>th bit from
<var class="var">ei3</var>.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dbit_002dcount"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-bit-count</strong> <var class="def-var-arguments">ei</var><a class="copiable-link" href="#index-bitwise_002dbit_002dcount"> &para;</a></span></dt>
<dd><p>Returns the number of 1 bits in the two&rsquo;s complement representation of
<var class="var">ei</var>.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dlength"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-length</strong> <var class="def-var-arguments">ei</var><a class="copiable-link" href="#index-bitwise_002dlength"> &para;</a></span></dt>
<dd><p>Returns the number of bits necessary to represent <var class="var">ei</var>.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dfirst_002dbit_002dset"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-first-bit-set</strong> <var class="def-var-arguments">ei</var><a class="copiable-link" href="#index-bitwise_002dfirst_002dbit_002dset"> &para;</a></span></dt>
<dd><p>Returns the index of the least significant 1 bit in the two&rsquo;s complement
representation of <var class="var">ei</var>.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dbit_002dset_003f"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-bit-set?</strong> <var class="def-var-arguments">ei1 ei2</var><a class="copiable-link" href="#index-bitwise_002dbit_002dset_003f"> &para;</a></span></dt>
<dd><p>Returns <code class="code">#t</code> if the <var class="var">ei2</var>th bit in the two&rsquo;s complement
representation of <var class="var">ei1</var> is 1, <code class="code">#f</code> otherwise.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dcopy_002dbit"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-copy-bit</strong> <var class="def-var-arguments">ei1 ei2 ei3</var><a class="copiable-link" href="#index-bitwise_002dcopy_002dbit"> &para;</a></span></dt>
<dd><p>Returns the result of setting the <var class="var">ei2</var>th bit of <var class="var">ei1</var> to the
<var class="var">ei2</var>th bit of <var class="var">ei3</var>.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dbit_002dfield"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-bit-field</strong> <var class="def-var-arguments">ei1 ei2 ei3</var><a class="copiable-link" href="#index-bitwise_002dbit_002dfield"> &para;</a></span></dt>
<dd><p>Returns the integer representation of the contiguous sequence of bits in
<var class="var">ei1</var> that starts at position <var class="var">ei2</var> (inclusive) and ends at
position <var class="var">ei3</var> (exclusive).
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dcopy_002dbit_002dfield"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-copy-bit-field</strong> <var class="def-var-arguments">ei1 ei2 ei3 ei4</var><a class="copiable-link" href="#index-bitwise_002dcopy_002dbit_002dfield"> &para;</a></span></dt>
<dd><p>Returns the result of replacing the bit field in <var class="var">ei1</var> with start
and end positions <var class="var">ei2</var> and <var class="var">ei3</var> with the corresponding bit
field from <var class="var">ei4</var>.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002darithmetic_002dshift"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-arithmetic-shift</strong> <var class="def-var-arguments">ei1 ei2</var><a class="copiable-link" href="#index-bitwise_002darithmetic_002dshift"> &para;</a></span></dt>
<dt class="deffnx def-cmd-deffn" id="index-bitwise_002darithmetic_002dshift_002dleft"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-arithmetic-shift-left</strong> <var class="def-var-arguments">ei1 ei2</var><a class="copiable-link" href="#index-bitwise_002darithmetic_002dshift_002dleft"> &para;</a></span></dt>
<dt class="deffnx def-cmd-deffn" id="index-bitwise_002darithmetic_002dshift_002dright"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-arithmetic-shift-right</strong> <var class="def-var-arguments">ei1 ei2</var><a class="copiable-link" href="#index-bitwise_002darithmetic_002dshift_002dright"> &para;</a></span></dt>
<dd><p>Returns the result of shifting the bits of <var class="var">ei1</var> right or left by
the <var class="var">ei2</var> positions. <code class="code">bitwise-arithmetic-shift</code> is identical
to <code class="code">bitwise-arithmetic-shift-left</code>.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002drotate_002dbit_002dfield"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-rotate-bit-field</strong> <var class="def-var-arguments">ei1 ei2 ei3 ei4</var><a class="copiable-link" href="#index-bitwise_002drotate_002dbit_002dfield"> &para;</a></span></dt>
<dd><p>Returns the result of cyclically permuting the bit field in <var class="var">ei1</var>
with start and end positions <var class="var">ei2</var> and <var class="var">ei3</var> by <var class="var">ei4</var> bits
in the direction of more significant bits.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-bitwise_002dreverse_002dbit_002dfield"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">bitwise-reverse-bit-field</strong> <var class="def-var-arguments">ei1 ei2 ei3</var><a class="copiable-link" href="#index-bitwise_002dreverse_002dbit_002dfield"> &para;</a></span></dt>
<dd><p>Returns the result of reversing the order of the bits of <var class="var">ei1</var>
between position <var class="var">ei2</var> (inclusive) and position <var class="var">ei3</var>
(exclusive).
</p></dd></dl>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="rnrs-syntax_002dcase.html">rnrs syntax-case</a>, Previous: <a href="rnrs-arithmetic-flonums.html">rnrs arithmetic flonums</a>, Up: <a href="R6RS-Standard-Libraries.html">R6RS Standard Libraries</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>