bitsliceget - Consecutive slice of bits

Syntax

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

Description

c = bitsliceget(a) returns the entire set of bits in the fi object a. If a has a signed numerictype, the bit representation of the stored integer is in two's complement representation.

c = bitsliceget(a, lidx) returns a consecutive slice of bits from a starting at position lidx and ending at the LSB (the bit at position 1). lidx is a constant that represents the position in the slice that is closest to the MSB.

c = bitsliceget(a, lidx, ridx) returns a consecutive slice of bits from a starting at position lidx and ending at position ridx. ridx is a constant that represents the position in the slice that is closest to the LSB.

The bitsliceget arguments must satisfy the following condition:

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

If lidx and ridx are equal, bitsliceget only slices one bit, and bitsliceget(a, lidx, ridx) is the same as bitget(a, lidx).

bitsliceget only supports fi objects with fixed-point data types. bitsliceget always returns a fixed point number with no scaling and with word length equal to slice length, lidx-ridx+1.

Example

This example shows how to get the binary representation of a specified set of consecutive bits in a fi object. Consider the following unsigned fixed-point fi object with a value of 85, word length 8, and fraction length 0:

a = fi(85,0,8,0);
disp(bin(a))

01010101

Get the binary representation of the consecutive set of bits starting at position 8 and ending at position 3:

bits8to3 = bitsliceget(a,8,3);
disp(bin(bits8to3))

010101

See Also

bitand, bitcmp, bitget, bitor, bitset, bitxor

  


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