Theocacao
Leopard
Design Element
Comment on "CocoaHeads: Objective-C 2.0"
by Eric Wing — Sep 17
FYI, C99 supports complex numbers. Example:

#include <complex.h> #include <stdio.h> int main(int argc, char* argv[]) { float complex my_result; float _Complex my_complex1 = 3.0 + 4.0*I; float complex my_complex2 = 1.0 + 2.0*_Complex_I; my_result = my_complex1 + my_complex2; printf("Add: %f + %fi\n", creal(my_result), cimag(my_result)); my_result = my_complex1 * my_complex2; printf("Multiply: %f + %fi\n", creal(my_result), cimag(my_result)); return 0; }

Obj-C is a pure superset of C; no need to write your own class in this case.
Back to "CocoaHeads: Objective-C 2.0"
Design Element

Copyright © Scott Stevenson 2004-2015