Fixnums are small exact integers that can be represented without heap allocation (see this note for more information). Larceny never represents a number that can be represented as a fixnum any other way, so programs that can use fixnums will do so automatically. However, operations that work only on fixnums can sometimes be substantially faster than generic operations, and the following primitives are provided for use in those programs that need especially good performance.
All arguments to the following procedures must be fixnums.
(fixnum? obj) => boolean
Returns #t if its argument is a fixnum, and #f otherwise.
(fx+ fix1 fix2) => fixnum
Returns the fixnum sum of its arguments. If the result is not representable as a fixnum, then an error is signalled (unless error checking has been disabled).
(fx- fix1 fix2) => fixnum
Returns the fixnum difference of its arguments. If the result is not representable as a fixnum, then an error is signalled.
(fx-- fix1) => fixnum
Returns the fixnum negative of its argument. If the result is not representable as a fixnum, then an error is signalled.
(fx* fix1 fix2) => fixnum
Returns the fixnum product of its arguments. If the result is not representable as a fixnum, then an error is signalled.
(fx= fix1 fix2) => boolean
Returns #t if its arguments are equal, and #f otherwise.
(fx< fix1 fix2) => boolean
Returns #t if fix1 is less than fix2, and #f otherwise.
(fx<= fix1 fix2) => boolean
Returns #t if fix1 is less than or equal to fix2, and #f otherwise.
(fx> fix1 fix2) => boolean
Returns #t if fix1 is greater than fix2, and #f otherwise.
(fx>= fix1 fix2) => boolean
Returns #t if fix1 is greater than or equal to fix2, and #f otherwise.
(fxnegative? fix) => boolean
Returns #t if its argument is less than zero, and #f otherwise.
(fxpositive? fix) => boolean
Returns #t if its argument is greater than zero, and #f otherwise.
(fxzero? fix) => boolean
Returns #t if its argument is zero, and #f otherwise.
(logand fix1 fix2) => fixnum
Returns the bitwise and of its arguments.
(logior fix1 fix2) => fixnum
Returns the bitwise inclusive or of its arguments.
(lognot fix) => fixnum
Returns the bitwise not of its argument.
(logxor fix1 fix2) => fixnum
Returns the bitwise exclusive or of its arguments.
(lsh fix1 fix2) => fixnum
Returns fix1 shifted left fix2 places, shifting in zero bits at the low end. If the shift count exceeds the number of bits in the machine's word size, then the results are machine-dependent.
(most-positive-fixnum) => fixnum
Returns the largest representable positive fixnum.
(most-negative-fixnum) => fixnum
Returns the smallest representable negative fixnum.
(rsha fix1 fix2) => fixnum
Returns fix1 shifted right fix2 places, shifting in a copy of the sign bit at the left end. If the shift count exceeds the number of bits in the machine's word size, then the results are machine-dependent.
(rshl fix1 fix2) => fixnum
Returns fix1 shifted right fix2 places, shifting in zero bits at the high end. If the shift count exceeds the number of bits in the machine's word size, then the results are machine-dependent.