CKTIS / C
Operator -: subtraction and negation
Operator - subtracts two values or negates one value; its meaning depends on the operands.
Version: C23; repository compiler flag, production runtime not attested
Syntax
a - b
-x
p - n
p - qBinary a - b computes a difference after the usual arithmetic conversions. Unary -x negates an arithmetic operand after integer promotions. Neither form itself modifies its operands.
Signed integer overflow is undefined, including -INT_MIN. Unsigned arithmetic is modular: check the resulting type after promotions.
p - n moves a pointer back n elements, staying within its array or one past it. In p - q, the pointers must point to qualified or unqualified versions of compatible complete object types. The qualifiers need not match, as with int * and const int *. Each pointer must point to an element of the same array or one past its end. The index difference must fit in ptrdiff_t.
Examples
#include <stdio.h>
int main(void)
{
int a = 9;
int b = 4;
printf("%d %d\n", a - b, -a);
return 0;
}
Result
5 -9
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.