integer
Factor handbook > The language > Numbers > Integers

Next:fixnum? ( object -- ? )


Vocabulary
math

Class description
The class of integers, which is a disjoint union of fixnums and bignums.

Definition


Methods




M: integer (B) { 24 { 1 25 } { 0 26 } { 1 27 } 0 } insn ;



















































M: integer B -2 shift 0 0 18 i-insn ;





























































































M: integer frexp
[ 0.0 0 ] [
dup 0 > [ 1 ] [ abs -1 ] if swap dup log2 [
52 swap - shift 4503599627370495 bitand
0.5 double>bits bitor bits>double
] [ 1 + ] bi [ * ] dip
] if-zero ; inline












M: integer item>xml
dup 31 2^ neg 31 2^ 1 - between?
[ "Integers must fit in 32 bits" throw ] unless 1 nenum T{
xml-chunk
{ seq
V{
""
T{ tag { name ~name~ } { children ~vector~ } }
""
}
}
} interpolate-xml ;




























































































































































M: integer write-msgpack
dup 0 >= [
{
{ [ dup 127 <= ] [ write1 ] }
{ [ dup 255 <= ] [ 204 write1 write1 ] }
{ [ dup 65535 <= ] [ 205 write1 2 >be write ] }
{ [ dup 4294967295 <= ] [ 206 write1 4 >be write ] }
{
[ dup 18446744073709551615 <= ]
[ 207 write1 8 >be write ]
}
[ cannot-convert ]
} cond
] [
{
{ [ dup -31 >= ] [ write1 ] }
{ [ dup -128 >= ] [ 208 write1 write1 ] }
{ [ dup -32768 >= ] [ 209 write1 2 >be write ] }
{
[ dup -2147483648 >= ]
[ 210 write1 4 >be write ]
}
{
[ dup -9223372036854775808 >= ]
[ 211 write1 8 >be write ]
}
[ cannot-convert ]
} cond
] if ;