fixnum - Factor Documentation (original) (raw)
Class description
The class of fixnums, which are fixed-width integers small enough to fit in a machine cell. Because they are not heap-allocated, fixnums do not have object identity. Equality of tagged pointer bit patterns is actually value equality for fixnums.
USING: kernel.private math math.bitwise.private ;
M: fixnum (bit-count) fixnum-bit-count { fixnum } declare ;
inline
USING: bootstrap.image.private kernel math ;
USING: kernel.private math math.functions.private ;
M: fixnum (integer-log10)
fixnum-integer-log10 { fixnum } declare ; inline
USING: kernel.private math math.integers.private math.private ;
M: fixnum (log2) fixnum-log2 { fixnum } declare ; inline
USING: kernel kernel.private math math.integers.private ;
M: fixnum /f
{ fixnum fixnum } declare 2dup
[ abs bignum/f-threshold >= ] either?
[ bignum/f ] [ fixnum/f ] if ; inline
M: fixnum /i fixnum/i ; inline
M: fixnum /mod fixnum/mod ; inline
M: fixnum <= fixnum<= ; inline
M: fixnum >= fixnum>= ; inline
USING: arrays asn1 kernel math pack sequences ;
M: fixnum >ber
>128-ber dup length 2 swap 2array "cc" pack-native
B{ } prepend-as ;
M: fixnum >bignum fixnum>bignum ; inline
M: fixnum >float fixnum>float ; inline
USING: math python python.errors python.ffi ;
M: fixnum >py PyLong_FromLong check-new-ref ;
USING: math math.functions.private ;
USING: math math.integers.private ;
M: fixnum bit? integer>fixnum-strict fixnum-bit? ; inline
M: fixnum bitand fixnum-bitand ; inline
M: fixnum bitnot fixnum-bitnot ; inline
M: fixnum bitor fixnum-bitor ; inline
M: fixnum bitxor fixnum-bitxor ; inline
USING: compiler.tree.propagation.info kernel math ;
USING: kernel math math.private ;
M: fixnum equal?
over bignum? [ >bignum bignum= ] [ 2drop f ] if ; inline
USING: elevate.private kernel math ;
M: fixnum failed-process? -1 = ;
M: fixnum hashcode* nip ; inline
M: fixnum integer>fixnum ; inline
M: fixnum integer>fixnum-strict ; inline
USING: generic kernel math math.integers.private math.order ;
M: fixnum max
over fixnum?
[ fixnum-max ] [ M\ fixnum max (call-next-method) ] if ;
inline
USING: generic kernel math math.integers.private math.order ;
M: fixnum min
over fixnum?
[ fixnum-min ] [ M\ fixnum min (call-next-method) ] if ;
inline
M: fixnum mod fixnum-mod ; inline
USING: combinators generic math namespaces tools.deploy.test.7 ;
M: fixnum my-generic
M\ fixnum my-generic (call-next-method)
my-var get ( a -- b ) call-effect ;
M: fixnum number= eq? ; inline
USING: kernel math math.parser.private sbufs sequences ;
M: fixnum positive>dec
1 over count-digits fixnum>dec "" like reverse! nip ;
inline
USING: bootstrap.image.private kernel layouts math math.order ;
M: fixnum prepare-object
dup bootstrap-most-negative-fixnum
bootstrap-most-positive-fixnum between?
[ tag-fixnum ] [ >bignum prepare-object ] if ;
USING: math random random.private ;
M: fixnum random* random-integer ;
USING: kernel.private math math.order.private ;
M: fixnum real<=> { fixnum fixnum } declare (real<=>) ; inline
M: fixnum shift integer>fixnum fixnum-shift ; inline
M: fixnum simple-gcd fixnum-gcd ; inline
USING: kernel layouts math math.cardinality ;
M: fixnum trailing-zeros
[ fixnum-bits ]
[ 0 [ over even? ] [ [ 2/ ] [ 1 + ] bi* ] while nip ]
if-zero ;