unsigned

Used in variable declarations as a Type-Specifier to indicate that the variable cannot be marked with a negative sign. The minimum value is 0. It applies to char, int, and long data types.

The following table illustrates the difference between signed and unsigned variables.

Type Size Unsigned Signed (normal)
char8 bits 0 to 255 -128 to 127
int16 bits 0 to 65,535 -32,768 to 32,767
long32 bits 0 to 4,294,967,295 -2,147,483,648 to 2,147,483,647

Example

The following example loops through a string, str, in search of the first non-numeric character. The variable len is an unsigned type, because no negative values can be attributed to the length of a string.

    int is_digit, i = 0;
    char * str = "1234567k89";
    unsigned int len = strlen(str);
    do {
        if (i == len) {
            lr_output_message ("No letters found in string");
            return -1;
        }
        is_digit = isdigit(str[i++]);
    } while (is_digit);
         lr_output_message ("The first letter appears in character %d of string", i);
Example: Output:
Action.c(18): The first letter appears in character 8 of string