dmaze ([personal profile] dmaze) wrote2003-07-10 11:52 am

Coding my way out of a brown paper bag

The language we're writing a compiler for has primitive support for complex numbers. Our current front-end is pretty much entirely my project, and one of our summer undergrads has been putting a lot of abuse on it -- a good thing, since some of our code doesn't get tested otherwise.

Today's bug: if you declare complex c = 1-2i;, the parser splits it into two parts, 1 - (0+2i). The complex-handling code then says, "aha! Binary expression! The first part is purely real, and the second is purely imaginary, so I take the real part from the first and the imaginary part from the second, and get 1+2i. All done!" See, nobody actually needs the bottom half of the complex plane for anything...

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org