lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Using <complex.h> now.  :)

Only to realize, _also_ that (on OS X, gcc 4.0.1) actually generates the _same_ inaccuracy... :&

-asko


David Jones kirjoitti 8.9.2006 kello 10.56:


On 7 Sep 2006, at 21:57, Asko Kauppi wrote:


Thanks:  was simply using the wrong formulas for pow.

Now, it still gives innacurate answers, but close to -1:

  Lua 5.1.1  Copyright (C) 1994-2006 Lua.org, PUC-Rio (complex)
  > a=1i
  > =a^2
  -1+1.2246467991474e-16i

Should something be done about this (like handling real powers separately)?

You mean you're not using <complex.h> and therefore cpow? I would expect any respectable cpow to handle integer y separately.

And if you're rolling you're own, then yes you should.

drj