The (rnrs arithmetic fixnums (6))
library provides procedures for
performing arithmetic operations on an implementation-dependent range of
exact integer values, which R6RS refers to as fixnums. In Guile,
the size of a fixnum is determined by the size of the SCM
type; a
single SCM struct is guaranteed to be able to hold an entire fixnum,
making fixnum computations particularly
efficient—(see The SCM Type). On 32-bit systems, the most
negative and most positive fixnum values are, respectively, -536870912
and 536870911.
Unless otherwise specified, all of the procedures below take fixnums as
arguments, and will raise an &assertion
condition if passed a
non-fixnum argument or an &implementation-restriction
condition
if their result is not itself a fixnum.
Returns #t
if obj is a fixnum, #f
otherwise.
These procedures return, respectively, the maximum number of bits necessary to represent a fixnum value in Guile, the minimum fixnum value, and the maximum fixnum value.
These procedures return #t
if their fixnum arguments are
(respectively): equal, monotonically increasing, monotonically
decreasing, monotonically nondecreasing, or monotonically nonincreasing;
#f
otherwise.
These numerical predicates return #t
if fx is,
respectively, zero, greater than zero, less than zero, odd, or even;
#f
otherwise.
These procedures return the maximum or minimum of their arguments.
These procedures return the sum or product of their arguments.
Returns the difference of fx1 and fx2, or the negation of fx, if called with a single argument.
An &assertion
condition is raised if the result is not itself a
fixnum.
These procedures implement number-theoretic division on fixnums; See (rnrs base), for a description of their semantics.
Returns the two fixnum results of the following computation:
(let* ((s (+ fx1 fx2 fx3)) (s0 (mod0 s (expt 2 (fixnum-width)))) (s1 (div0 s (expt 2 (fixnum-width))))) (values s0 s1))
Returns the two fixnum results of the following computation:
(let* ((d (- fx1 fx2 fx3)) (d0 (mod0 d (expt 2 (fixnum-width)))) (d1 (div0 d (expt 2 (fixnum-width))))) (values d0 d1))
Returns the two fixnum results of the following computation: (let* ((s (+ (* fx1 fx2) fx3)) (s0 (mod0 s (expt 2 (fixnum-width)))) (s1 (div0 s (expt 2 (fixnum-width))))) (values s0 s1))
These procedures are identical to the lognot
, logand
,
logior
, and logxor
procedures provided by Guile’s core
library. See Bitwise Operations, for documentation.
Returns the bitwise “if” of its fixnum arguments. The bit at position
i
in the return value will be the i
th bit from fx2
if the i
th bit of fx1 is 1, the i
th bit from
fx3.
Returns the number of 1 bits in the two’s complement representation of fx.
Returns the number of bits necessary to represent fx.
Returns the index of the least significant 1 bit in the two’s complement representation of fx.
Returns #t
if the fx2th bit in the two’s complement
representation of fx1 is 1, #f
otherwise.
Returns the result of setting the fx2th bit of fx1 to the fx2th bit of fx3.
Returns the integer representation of the contiguous sequence of bits in fx1 that starts at position fx2 (inclusive) and ends at position fx3 (exclusive).
Returns the result of replacing the bit field in fx1 with start and end positions fx2 and fx3 with the corresponding bit field from fx4.
Returns the result of shifting the bits of fx1 right or left by
the fx2 positions. fxarithmetic-shift
is identical
to fxarithmetic-shift-left
.
Returns the result of cyclically permuting the bit field in fx1 with start and end positions fx2 and fx3 by fx4 bits in the direction of more significant bits.
Returns the result of reversing the order of the bits of fx1 between position fx2 (inclusive) and position fx3 (exclusive).