stefan-brus / dmath

Mathematical expression evaluator written in D
2 stars 0 forks source link

Add complex numbers #18

Closed stefan-brus closed 10 years ago

stefan-brus commented 10 years ago

Add support for complex numbers.

A complex number is a number that has a real part and an imaginary part, for example: 2 + 3i

A new type of expression for complex numbers containing 2 number expressions needs to be created, as well as updating every operator to be able to handle complex numbers. I hope D's magic templates can do this in a pretty way somehow.

As for how to handle user input complex numbers, the following syntax should be supported: {3 - 7i} 2 + 3i

In the first case, a new complex number expressions containing the values (3, -7) will be created. In the second case, the 3i will be translated as {0 + 3i}.

stefan-brus commented 10 years ago

A new field containing an enum with information about the result type of the expression could be added to the expression classes.