CT_INTPOS

 INTPOS()
 Converts a signed integer into an unsigned integer
------------------------------------------------------------------------------
 Syntax

     INTPOS(<nSigned|cHexSigned>,[<l32Bit>])
         --> nUnsigned

 Arguments

     <nUnsigned|cHexUnsigned>  Designates either a numeric value or
     hexadecimal digit string to convert into a 16-bit or 32-bit unsigned
     integer.

     <l32Bit>  If this optional parameter is designated as .T., the
     function processes the designated value as a 32-bit signed integer.  The
     default value is a 16-bit signed integer (.F.).

 Returns

     INTPOS() returns an unsigned 16-bit or 32-bit integer.

 Description

     This function converts signed 16-bit or 32-bit integers into the
     corresponding unsigned number.  Based on the optional parameter and the
     logical value it is assigned, you can work with 16-bit or 32-bit values.

     For the 16-bit variant, all values in the 0 to 32767 range are
     unchanged.  However, all negative values from -1 to -32768 are changed.
     When the optional parameter is designated as .T., the range of values
     stretches from -2147483648 to +2147483647.

 Note

     .  This function returns a 0 result for invalid paramerters.

 Examples

     .  Show simple conversions:

        ? INTPOS(-1)               // 65535
        ? INTPOS(-2)               // 65534
        ? INTPOS(30000)            // 30000
        ? INTPOS(60000)            // 60000

     Warning!  When working with 16-bit values INTPOS(0) = INTPOS(65536):

        ? INTPOS(0)                // 0
        ? INTPOS(65536)            // 0

     .  Show values larger than 65536 in 16-bit mode.  For example,
        the difference between 90000 and 65536 is 24464:

        ? INTPOS(90000)            // 24464

     .  However, in 32-bit mode:

        ? INTPOS(90000, .T.)       // 90000
        ? INTPOS(-1, .T.)          // 4294967295
                                   // (largest 32-bit number)
        ? INTPOS(-60000, .T.)      // 4294907296
        ? INTPOS(-90000, .T.)      // 4294877296

See Also: INTNEG() NUMAND() NUMOR() NUMXOR()

 

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