CT_NUMROL

 NUMROL()
 Performs a 16-bit left rotation of a number
------------------------------------------------------------------------------
 Syntax

     NUMROL(<nWORD1|cHexWORD1>,<nWORD2|cHexWORD2>,
        [<lLowByte>]) --> nWORDLeft-Rotated

 Arguments

     <nWORD1|cHexWORD1>  Designates a numeric or hexadecimal value in the
     range of 0 to 65535.

     <nWORD2|cHexWORD2>  Designates a number of rotations in the range of
     1 to 15 (1 to 7); as either numeric or hexadecimal.

     <lLowByte>  If this optional parameter is designated as .T., then
     the low byte of the specified WORD is rotated.  The default is a 16-bit
     rotation (.F.).

 Returns

     NUMROL() returns the rotation result.

 Description

     This function rotates bits to the left in a number between 0 and 65535
     (16-bit value).  When the high bit rotates it is not just moved out to
     the left, it is also moved in on the right.  Use the optional logical
     parameter to determine if all 16 or only the low value 8 bits are to
     rotate.

 Notes

     .  If a value of > 15(7) is designated for <nWORD1|cHexWORD1>,
        the actual number of rotations for the remainder corresponds to a
        value divided by 16(8).

     .  A right rotation is also possible.  One rotation to the right
        corresponds to 15(or 7) rotations to the left, etc..

 Examples

     .  Rotate the 1 value three times to the left:

        00000000 00000001  00000000 00001000
        ? NTOC(1, 2, 16, "0"), NTOC(NUMROL(1, 3), 2, 16, "0")
                                         // Display as binary

     .  Value of 60000 -- only rotate the low 8-bit value:

        11101010 01100000  11101010 10000001
        NUMROL(60000, 2, .T.)

     .  Construct a rotation two places to the right:

        00000000 00000100  00000000 00000001
        ? NUMROL(4, 14)

     .  In parameter 2 > 15, there is only one rotation:

        ? NUMROL(1, 33)                  // Result:  2

See Also: NTOC()



Tools – Numbers/Bit Manipulation

Introduction
BITTOC()     Converts position-dependent bits into characters
CELSIUS()    Converts a Fahrenheit temperature value into Celsius
CLEARBIT()   Clears one or more bits within a number to zero
CTOBIT()     Converts a character string into a bit pattern
CTOF()       Converts a special 8-byte string into a floating point number
CTON()       Converts a numeric string into a different base
EXPONENT()   Determines the exponent of a floating point number (base 2)
FAHRENHEIT() Converts a temperature value from Celsius into Fahrenheit
FTOC()       Converts a floating point number into a special 8-byte string
INFINITY()   Creates the largest number possible (21023)
INTNEG()     Converts an unsigned integer into a signed integer
INTPOS()     Converts a signed integer into an unsigned integer
ISBIT()      Tests the bits in a number
LTON()       Converts a logical value into a numeric value
MANTISSA()   Determines the mantissa of a floating point number (base2)
NTOC()       Converts numbers in a digit string into a different number base
NUMAND()     Performs a 16-bit "AND" of a list of numbers
NUMCOUNT()   Uses the internal CA-Clipper Tools counter
NUMHIGH()    Returns the higher value byte in a 16-bit number
NUMLOW()     Returns the lower value byte in a 16-bit number
NUMMIRR()    Mirrors 8-bit or 16-bit values
NUMNOT()     Performs a 16-bit "NOT" of a number
NUMOR()      Performs a 16-bit "OR" of a list of numbers
NUMROL()     Performs a 16-bit left rotation of a number
NUMXOR()     Performs a 16-bit "XOR" of two numbers
RAND()       Generates random numbers
RANDOM()     Generates random numbers
SETBIT()     Sets one or more bits in a number