The racket/fixnum library provides operations like fx+ that consume and produce only fixnums. The operations in this library are meant to be safe versions of unsafe operations like unsafe-fx+ . These safe operations are generally no faster than using generic primitives like + .
The expected use of the racket/fixnum library is for code where the require of racket/fixnum is replaced with
See the documentation of filtered-in for use with #lang racket/base.
racket/unsafe/ops))
to drop in unsafe versions of the library. Alternately, when encountering crashes with code that uses unsafe fixnum operations, use the racket/fixnum library to help debug the problems.
Changed in version 7.0.0.13 of package base: Allow zero or more arguments for fx+ and fx* and one or more arguments for fx- .
Changed in version 7.0.0.13 of package base: Allow any number of arguments for fxand , fxior , and fxxor .
procedure
( fxpopcount32 a)→fixnum?
procedure
( fxpopcount16 a)→fixnum?
Added in version 8.5.0.7 of package base.
Added in version 7.9.0.6 of package base.
Changed in version 8.15.0.12: Changed fx-/wraparound to accept a single argument.
procedure
( fxrshift/logical ab)→fixnum?
a:fixnum?b:fixnum?
32
15
#t
Added in version 8.8.0.5 of package base.
Changed in version 7.0.0.13 of package base: Allow one argument, in addition to allowing two or more.
The fx->fl function is the same as exact->inexact or ->fl constrained to a fixnum argument.
The fl->fx function is the same as truncate followed by inexact->exact or fl->exact-integer constrained to returning a fixnum. If the truncated flonum does not fit into a fixnum, the exn:fail:contract exception is raised.
Changed in version 7.7.0.8 of package base: Changed fl->fx to truncate.
procedure
v:any/c
Added in version 7.3.0.11 of package base.
A fxvector is like a vector, but it holds only fixnums. The only advantage of a fxvector over a vector is that a shared version can be created with functions like shared-fxvector .
Two fxvectors are equal? if they have the same length, and if the values in corresponding slots of the fxvectors are equal? .
A printed fxvector starts with #fx(, optionally with a number between the #fx and (. See Reading Vectors for information on read ing fxvectors and Printing Vectors for information on print ing fxvectors.
(fxvector 2 3 4 5)
procedure
( make-fxvector size[x])→fxvector?
(fxvector 3 3 3 3)
procedure
vec:fxvector?
procedure
( fxvector-ref vecpos)→fixnum?
vec:fxvector?
procedure
( fxvector-set! vecposx)→fixnum?
vec:fxvector?x:fixnum?
procedure
( fxvector-copy vec[startend])→fxvector?
vec:fxvector?
procedure
( in-fxvector vec[startstopstep])→sequence?
vec:fxvector?
The optional arguments start, stop, and step are as in in-vector .
An in-fxvector application can provide better performance for fxvector iteration when it appears directly in a for clause.
syntax
( for/fxvector maybe-length(for-clause...)body...)
syntax
( for*/fxvector maybe-length(for-clause...)body...)
maybe-length =| #:lengthlength-expr| #:lengthlength-expr#:fillfill-exprlength-expr : exact-nonnegative-integer?fill-expr : fixnum?
procedure
( shared-fxvector x...)→fxvector?
x:fixnum?
(fxvector 2 3 4 5)
procedure
( make-shared-fxvector size[x])→fxvector?
(fxvector 3 3 3 3)
procedure
procedure
Added in version 8.1.0.7 of package base.