xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

NumRoL()

Rotates bits of a numeric 16-bit integer value to the left.

Syntax

NumRoL( <nInteger>|<cHex>  , ;
        <nRotate>|<cRotate>, ;
       [<lEightBits>]        ) --> nInteger

Arguments

<nInteger>
A numeric 16-bit integer value in the range between 0 and 65535 can be specified as first parameter.
<cHex>
Alternatively, the integer can be passed as a hex-encoded character string (see NumToHex()).
<nRotate>
A numeric value in the range between 1 and 15 defines how many places the bits should be rotated. If <lEightBits> is set to .T. (true), the range is between 1 and 7.
<cRotate>
Instead of a numeric value, the parameter can be a hex-encoded character string.
<lEightBits>
If .T. (true) is passed for <lEightBits>, only the low 8 bits of <nInteger> are rotated. The default value is .F. (false), i.e. all 16 bits are rotated.

Return

The function returns the result of the bit rotation as a numeric value.

Info

See also:<<, >>, NumRolX(), NtoC()
Category: CT:NumBits , Bitwise functions , Numbers and Bits
Source:ct\bit1.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays the results of left bit rotation and their
// binary representation. Note that the most significant bit replaces
// the least significant bit in a rotation, while all other bits are
// shifted to the left.

   PROCEDURE Main
      LOCAL nValue := CtoN( "0010100001110000", 2 )

      ? nValue                     // result: 10352
      ? NtoC( nValue, 2, 16, "0" )
                        // result: 0010100001110000

      ? NumRol( nValue, 3 )        // result: 17281
      ? NtoC( NumRol( nValue, 3 ), 2, 16, "0" )
                        // result: 0100001110000001

      ? NumRol( nValue, 3, .T. )   // result: 10371
      ? NtoC( NumRol( nValue, 3, .T. ), 2, 16, "0" )
                        // result: 0010100010000011
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe