PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. Along with the proper indenting it makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. This will not automatically indent your code. That part is up to you. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |
num1 + num2;
you could use an "int" or "double". These days a "double" is the preferred floating point type. Even then a "float" or "double" may not store the decimal number properly. An example: num = 0.3;
. You would think this would store as "0.3
", but you are more likely to get "0.29999999999999989
and I have see a float store the decimal part higher than the entered number.The effect of instantiating the template complex for any type other than float, double, or long double is unspecified - IS https://eel.is/c++draft/complex.numbers |
|
|