Converts an unsigned integer into a signed integer

         --> nSigned


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

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


     INTNEG() returns a signed 16-bit or 32-bit integer.


     This function converts unsigned integers into signed integers.

     All 16-bit or 32-bit integers are accepted, depending on whether there
     is a second parameter and the logical value is assigned.  For the 16-bit
     variant, all values for <nUnsigned|cHexUnsigned> that are less than or
     equal to +32767 (hex=7FFF), are positive.  Values in the range of +32768
     (hex=8000) to +65535 (hex=FFFF), have a negative result.  When you work
     with 32-bit values, the positive range goes to 2147483647 (inclusive).
     All values beyond that are negative.


     .  The function returns a value of 0 for invalid, too large, or
        negative parameters.


     .  Show valid parameters:

        ? INTNEG(0)                   // Result:  0
        ? INTNEG(-1)                  // Result:  0
        ? INTNEG(30000)               // Result:  30000
        ? INTNEG(32767)               // Result:  32767
        ? INTNEG(32768)               // Result: -32768
        ? INTNEG(32769)               // Result: -32767
        ? INTNEG(60000)               // Result: -5536
        ? INTNEG(65535)               // Result: -1
        ? INTNEG("FFFF")              // Result: -1
        ? INTNEG("D0000000", .T.)     // Result: -805306368
        ? INTNEG("FFFFFFFF", .T.)     // Result: -1

     .  Show incorrect instructions or instructions that are too

        ? INTNEG("GGGG")              // Result:  0
        ? INTNEG(90000)               // Result:  0
        ? INTNEG("FFFFFFFFF")         // Result:  0



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.