Please note that the recommended version of Scilab is 6.0.2. This page might be outdated.
See the recommended documentation of this function
bitor
bitwise logical OR between elementwise integers of 2 arrays
Syntax
w = bitor(u, v)
Parameters
 u, v, w
scalars, vectors, matrices or hypermatrices of null or positive integers encoded as decimal or integer numbers of any signed or unsigned inttype.
Sparseencoded matrices are not accepted.If
u
andv
have the same type and inttype, this one is the working one. Otherwise, if
u
orv
is decimalencoded, the working inttype is 0 (real decimal), even if the other operand is int64 or uint64encoded.  if
u
andv
are both encoded integers, the working inttype is the widest of both: int8 < uint8 < int16 < uint16 < int32 < uint32 < int64 < uint64.
The result
w
gets the type of the working encoding.u
andv
are processed elementwise: If
u
is a single value (scalar) andv
is a vector, matrix or hypermatrix,u
is priorly expanded asu*ones(v)
in order to operateu
with everyv
component.  Conversely,
v
is priorly expanded asv*ones(u)
if it is a single value.  If neither
u
norv
are scalars, they must have the same sizes.
w
gets the sizes ofu
or/andv
arrays. if
Description
For each pair of componentsu(i)
and v(i)
,
bitor(u, v)
computes and returns in w(i)
the bitwise OR conjunction of u(i)
and v(i)
bits.
With encoded integers, bitor(u, v) is equivalent
to u  v . However, u  v
demands that u and v have
the same inttype, while bitor(..) accepts
mixed operands. 
For any decimal integer u greater than 2^52,
only its bits from log2(u) down to log2(u)52 are encoded and can
be actually taken into account. Lower bits are not stored and are
then ignored. 
Examples
bitor(25, 33) dec2bin([25 33 57]') // binary representations
> bitor(25, 33) ans = 57. > dec2bin([25 33 57]')) ans = !011001 ! !100001 ! !111001 !
// Between 2 simple rows with zeros and ones u = [0 1 0 1]; v = [0 0 1 1]; bitor(u, v) // [0 1 1 1] expected // Encoded integers such as int8 are accepted: u = int8([0 1 0 1]); v = int8([0 0 1 1]); bitor(u, v) // Operands of mixed types are accepted. // The type of the result is decimal if a decimal operand is involved, // or the widest integer one otherwise: u = [0 1 0 1]; v = [0 0 1 1]; z = bitor(u, int64(v)); type(z) // 1 : decimal representation z = bitor(uint8(u), int8(v)); typeof(z) // uint8 z = bitor(uint8(u), int32(v)); typeof(z) // int32 // Usage with 2 matrices u = [ 1 2 4 8 25 33 25 33 ]; v = [ 2 4 8 16 33 25 57 57 ]; bitor(u, v) // [ 3 6 12 24 ; 57 57 57 57 ] expected // Usage with a distributed scalar: bitor([1 2 4 8 9 10 12], 8) // == bitor([1 2 4 8 9 10 12], [8 8 8 8 8 8 8]) bitor(4, [1 2 4 8 9 10 12]) // == bitor([4 4 4 4 4 4 4], [1 2 4 8 9 10 12])
// With encoded integers, bitor(u,v) and uv are equivalent: u = int8([2 3 10]); v = int8(6); [bitor(u, v) ; u  v] // ... but "" demands operands with the same type: u  6 // mismatching int8  decimal encodings
> u = int8([2 3 10]); > v = int8(6); > [bitor(u, v) ; u  v] ans = 6 7 14 6 7 14 > u  6 Undefined operation for the given operands. check or define function %i_g_s for overloading.
// Examples with big decimal integers: u = sum(2 .^(600+[0 3 9 20 45])) // ~ 1.46D+194 v = 2^630 // ~ 4.46D+189 w = bitor(u, v) w == (u+v) // must be true, since u is built without the bit #630 bitor(u, 2^645) == u // true, since u has already its bit #645 set to 1 bitor(u, 2^601) == u // false // n = fix(log2(u)) // Index of the heaviest bit of u bitor(u, 2^(n52)) == u // false: The lightest bit of u was at 0 => This changes it bitor(u, 2^(n53)) == u // true: Addressing bits below the lightest doesn't change u
See also
  — Binary OR between integers. Logical OR over/between booleans and numbers
 or — OU logique entre éléments d'un tableau booléen ou numérique
 bitxor — bitwise logical XOR between elementwise integers of 2 arrays
 bitand — bitwise logical AND between elementwise integers of 2 arrays
 dec2bin — convert from decimal to binary
History
Version  Description 
6.0 

Comments
Add a comment:
Please login to comment this page.