Skip to Main Content Skip to Search
Product Documentation

bitorreduce - Bitwise OR of consecutive range of bits

Syntax

c = bitorreduce(a)
c = bitorreduce(a, lidx)
c = bitorreduce(a, lidx, ridx)

Description

c = bitorreduce(a) performs a bitwise OR operation on the entire set of bits in the fi object a and returns the result as a u1,0 (unsigned integer of word length 1).

c = bitorreduce(a, lidx) performs a bitwise OR operation on a consecutive range of bits starting at position lidx and ending at the LSB (the bit at position 1). lidx is a constant that represents the position in the range closest to the MSB.

c = bitorreduce(a, lidx, ridx) performs a bitwise OR operation on a consecutive range of bits starting at position lidx and ending at position ridx. ridx is a constant that represents the position in the range closest to the LSB.

The bitorreduce arguments must satisfy the following condition:

a.WordLength >= lidx >= ridx >= 1

a can be a scalar fi object or a vector fi object.

bitorreduce only supports fi objects with fixed-point data types; it does not support inputs with complex data types.

bitorreduce supports both signed and unsigned inputs with arbitrary scaling. The sign and scaling properties do not affect the result type and value. bitorreduce performs the operation on a two's complement bit representation of the stored integer.

Examples

This example shows how to perform a bitwise OR operation on a range of bits of a fi object. Consider the following unsigned fixed-point fi object with a value 5, word length 4, and fraction length 0:

a = fi(5,0,4,0);
disp(bin(a))

0101

Get the bitwise OR of the consecutive set of bits starting at position 4 and ending at position 3:

disp(bin(bitorreduce(a,4,3)))

1

See Also

bitandreduce | bitconcat | bitsliceget | bitxorreduce

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS