Handbook
Glossary
interval-bitand ( i1 i2 -- i3 )
Factor handbook
»
The language
»
Numbers
»
Intervals
»
Interval arithmetic
Prev:
interval-shift ( i1 i2 -- i3 )
Next:
interval-bitor ( i1 i2 -- i3 )
Vocabulary
math
.
intervals
Inputs
i1
an
interval
i2
an
interval
Outputs
i3
an
interval
Word description
Outputs an interval containing all possible values obtained by applying
bitand
to elements of
i1
and
i2
.
Definition
USING:
accessors
combinators
kernel
math
math.intervals.private
sequences
;
IN:
math.intervals
:
interval-bitand
( i1 i2 -- i3 )
[
{
{
[
2dup
[
interval-nonnegative?
]
both?
]
[
min-upper-bound
[0,b]
]
}
{
[
2dup
[
interval-nonnegative?
]
either?
]
[
dup
interval-nonnegative?
[
nip
]
[
drop
]
if
to>>
first
[0,b]
]
}
[
[
min-lower-bound
bit-weight
neg
]
[
2dup
[
interval-negative?
]
both?
[
min-upper-bound
]
[
max-upper-bound
]
if
]
2bi
[a,b]
]
}
cond
]
do-empty-interval
;