answersLogoWhite

0

I assume you refer to programming. Classes of complex numbers already exist for many programming languages (for instance, for Java); if you search for them, you can just use the ready-made classes, or - if you have a classroom task of writing your own class - at least get some useful ideas.The general idea is that you define a class with two fields - in Java that would be fields of type "double" - to store the real and imaginary part. Then you define methods for the desired operation and functions, such as addition, subtraction, multiplication, division, sine, cosine, exp, etc.

As an example, to add two numbers, the method "add" can add the number in the object on which it is invoked, and the other number can be passed as a parameter (argument); the answer can be written back to the object. This would be equivalent to:

a = a + b

As an alternative, you can pass two parameters (other complex numbers - i.e., other objects of the type "complex"), and make your object equal to the sum of the two. This would be equivalent to:

a = b + c


User Avatar

Wiki User

9y ago

Still curious? Ask our experts.

Chat with our AI personalities

JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra
JudyJudy
Simplicity is my specialty.
Chat with Judy

Add your answer:

Earn +20 pts
Q: How do you create a class of complex numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp