*I-M-A-G-E-N-A-R-Y Numbers*


#1

:scream: i’ve recently stumbled across something in my programming where i needed to calculate something using imagenary numbers (i.e. [font=CASIO FX]†-4 [font=Times New Roman]which is 2[color=white][font=CASIO FX]¿[/font]) however i have found no way to do this in c++,java,or darkbasic. does anybody know a way to make it not come up with a math error?[/color][/font][/font]


#2

Elaborate on exactly what it is you are trying to do and maybe someone can help. Generally you wouldn’t work with imaginary numbers in a game, you’d provide an inline or global constant or solve the equation to eliminate the imaginary number.


#3

sorry about some of the symbols i guess i was using a font that not every system has so if you dont have “casiofx” it will look weird.

actually the reason im doing it is that im trying to make a casio gc emulator for my lap top so that i dont have to bring my calculator everywhere i go. it has a complex mode that can calculate imagenary numbers.


#4

There are many standard math libraries in C++, and I’m sure for any other language, with classes that implement complex numbers (imaginary numbers are just a very special type of complex numbers). Google and you’ll find it. However, it’s quite easy to do it manually, basically a complex numbers is just a pair (a,b) of two real numbers, and there are simple formulas for adding, subtracting, multiplying, dividing, taking roots etc. The pair (a,b) represents the complex number a+bi where i is the square root of -1.

(a,b) + (c,d) = (a+c, b+d)
(a,b) - (c,d) = (a-c, b-d)
(a,b) * (c,d) = (ac-bd, ad+bc)
1 / (a,b) = (a/z, -b/z) where z=a^2+b^2

and so on…

AA


#5

Operator overloading and a solid foundation on exactly what you are trying to do.


#6

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.