fixnum-width(3scm)
π fixnum-width β the Scheme Programmer's Manual (3scm) π
okay so bestie, welcome to fixnum-width(3scm) β¨ this one lives in the Scheme Programmer's Manual and it's literally all about finding out how big your fixnums can get. short page, iconic energy, let's go π
πΈ NAME πΈ
fixnum-width, least-fixnum, greatest-fixnum β query the fixnum range ππ
π LIBRARY π
(import (rnrs)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
β¨ SYNOPSIS β¨
(fixnum-width)
(least-fixnum)
(greatest-fixnum)
π DESCRIPTION π
So the fixnum range is defined as the closed interval [β2^(wβ1), 2^(wβ1)β1] where w is an implementation-defined integer with w β₯ 24. That's the vibe π«
fixnum-widthreturns the implementation'sw. yep, just hands you the number π«Άleast-fixnumreturns β2^(wβ1). the smallest guy πgreatest-fixnumreturns 2^(wβ1)β1. the biggest guy π
The fixnum range is super important to keep in mind when you're using the fixnum procedures, because those procedures require that their arguments and results are fixnums. if a result can't be represented as a fixnum, they raise an exception. no cap, they will absolutely throw π
π§ IMPLEMENTATION NOTES π§
The fixnum width depends very much on implementation details and the machine. here are some known fixnum widths, bestie π
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. one value, one vibe, periodt π
π EXAMPLES π
; The results are different for different implementations.
(fixnum-width) => 61
(least-fixnum) => -1152921504606846976
(greatest-fixnum) => 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. and like, if the fixnum width is 32 (or greater) then fixnums can represent all signed 32-bit integers. slay π₯
β COMPATIBILITY β
This procedure is only present in R6RS. an alternative to (fixnum-width) is (+ 1 (bitwise-length (greatest-fixnum))). But normally there's no need to use fixnum procedures if they aren't 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. (not you calling it wrong π)
π SEE ALSO π
π STANDARDS π
R6RS
π§΅ HISTORY π§΅
These procedures are new to the fixnum library in R6RS. Implementations have always had some kind of fixnum type but it was normally not seen by the user. iykyk πΈ
π AUTHORS π
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/.
and that's the whole page, bestie!! π shoutout to the 2023-01-06 date and the fixnum-width(3scm) source/version, mwah π go forth and know your fixnum range πβ¨
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2021 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms