fixnumwidth, leastfixnum, greatestfixnum  query the fixnum range
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
SYNOPSIS
(fixnumwidth)
(leastfixnum)
(greatestfixnum)
DESCRIPTION
The fixnum range is defined as the closed interval
[−2^(w−1), 2^(w−1)−1]
such that w is an implementationdefined integer w ≥ 24.
The
fixnumwidth
procedure returns the implementation's w.
The
leastfixnum
procedure returns −2^(w−1).
The
greatestfixnum
procedure returns 2^(w−1)−1.
The fixnum range is important to consider when using the fixnum
procedures because these procedures require that their arguments and
results are fixnums. They raise an exception when a result cannot be
represented as a fixnum.
IMPLEMENTATION NOTES
The fixnum width depends very much on implementation details and the
machine. Here are some known fixnum widths.
 Chez Scheme


The fixnum width is 61 or 30. If the machine's register width is
m then the fixnum width is m  log2(m/8).
 GNU Guile

The fixnum width is 62 or 30. This is the machine's register width
minus two.
 IronScheme

The fixnum width is 32.
 Loko Scheme

The fixnum width is 61.
RETURN VALUES
These procedures each return a single value; a fixnum as per the
description above.
EXAMPLES
; The results are different for different implementations.
(fixnumwidth) => 61
(leastfixnum) => 1152921504606846976
(greatestfixnum) => 1152921504606846975
APPLICATION USAGE
This procedure is sometimes used in libraries that provide optimized
variants of code for implementations where the fixnum width is large
enough.
If the fixnum width is 32 (or greater) then fixnums can represent all
signed 32bit integers.
COMPATIBILITY
This procedure is only present in R6RS. An alternative to
(fixnumwidth) is (+ 1 (bitwiselength
(greatestfixnum))). But normally there is no need to use fixnum
procedures if they are not available; generic arithmetic can be used
instead and will give the same results.
ERRORS
This procedure can raise exceptions with the following condition types:
 &assertion (R6RS)

The wrong number of arguments was passed.
SEE ALSO
bitwiselength(3scm)
STANDARDS
R6RS
HISTORY
These procedures are new to the fixnum library in R6RS.
Implementations have always had some kind of fixnum type but was
normally not seen by the user.
AUTHORS
This page is part of the
schememanpages
project.
It includes materials from the RnRS documents.
More information can be found at
https://github.com/schemedoc/manpages/
.
Markup created by unroff 1.0sc, March 04, 2023.