division by zero mystery



As a hobby project, I am writing a C library of functions that do operations on complex numbers. I am also porting this code to Visual Basic (v.6) in the form of a calculator. I'm seeing something very odd. Code that generates a division by zero error in VB seems to work correctly in the C routines. For example, it is sometimes necessary to evaluate:

x = atan(b / a) (where a and b are the real and imag parts of a complex number)

This generates a division by zero error in VB when the complex operand is, for example, 0.0 + 1.0i but seems to work correctly in the C routines. That is, I can calculate i ^ i correctly with the C code but get a division by zero error when atan() is evaluated in VB. Any thoughts on why this is happening? Is it just "lucky" undefined behaviour?

JS
.



Relevant Pages

  • Re: division by zero mystery
    ... in VB seems to work correctly in the C routines. ... This generates a division by zero error in VB when the complex ... throw a floating point exception, ... atan() cannot guess the right quadrant like ...
    (comp.programming)
  • Re: Pepsi or Coca-Cola?
    ... into the street and beaten by an angry mob for writing.. ... Way outside the zone of zero error here, but I believe it to be around ... the time when Cadbury Beverages bought them. ...
    (rec.sport.football.college)