An operator named `@' and computing the absolute difference between its two real value operands may be defined as:
const struct x1f4_operator_type diff = { "@", difference, 0230, X1f4_E4_REAL, real2, 0, 1, NULL, NULL };
See struct x1f4_operator_type.
The name
field of the operator definition specifies the name of the
operator: `@'.
The operator
field selects the routine performing the operator logic, a
certain difference
function.
The priority
field specifies the operator evaluation priority - higher
the number, lower the priority.
The type
field specifies that the operator return type is real,
hence it translates X1f4_E4_REAL
.
See Symbolic Types.
The args
field specifies the types of the operator arguments and is
assumed defined as:
int real2[] = { X1f4_E4_REAL, X1f4_E4_REAL };
The flags
field specifies pretty much nothing in this operator
definition, hence is 0
.
The length
field specifies the operator name length, 1.
The obscure operator definition extensions go undefined here, hence
extension1
and extension2
are NULL
.
The difference
function realizes the absolute difference of two real
values.
int difference(void *context, void *output, void **input) { X1f4_E4_REAL a, b, *out; a = *(X1f4_E4_REAL *) input[0]; b = *(X1f4_E4_REAL *) input[1]; out = output; *out = fabs(a - b); return 0; }