The most basic way would be to create a struct defining each component of the number. Assuming you are only working in 1 dimension then your complex number will be of the form
ai+b
, and so your struct would look like
typedef struct {
float a;
float b;
} ComplexNumber;
Could you please provide the equation and indicate weather it needs to work on other similar equations or only this exact one and the operations that you are wanting to perform.
If it is a relatively simple equation like sqrt(-1) then there can be a simple answer without having to implement a complex numbers system.
ComplexNumber ComplexSqrt(float nNumber) {
ComplexNumber cnRes = { 0, 0 };
if (nNumber < 0) {
cnRes.a = sqrt(-nNumber);
} else {
cnRes.b = sqrt(nNumber);
}
return cnRes;
}