convert signed int to complex number

Can anyone advise hoe I can go from a signed 16 bit int to a complex number ?

eg. -32000 to complex number equivalent ?

http://lua-users.org/wiki/ComplexNumbers

To get a complex number you have to call the function complex.to( num )

Haven't used it though.. you will have to try it out!

thanks man!

The function (via Satheesh's link) wont work "as is". It might be possible to make it work, (loadstring isn't supported in Corona). let us know how you get on however

I'm finding corona's limitations sooo frustrating. This is my first time using it and it keeps throwing obstacles back at me!!

Danny
Q1 is there any other way to convert a 16bit signed int to a complex number in Corona?

Q2 Is there a list of other stuff Corona doesn't support like loadString?

In the complex numbers module,something like

1
2
3
4
local temp = tonumber(imag)
if temp then
    return setmetatable( { 0,temp }, complex_meta )
end

I appreciate your attempt Satheesh, but I'm no good at complex numbers. I'm afraid I can't comment on your 'mod' =)

Anyone know if Numeric Lua works with Corona ?
http://numlua.luaforge.net/

satheesh, I'm going to give your code a try

there's only 4 or 5 instances of loadstring in complex.lua so it might work!

what about this line?

loadstring("return tonumber("..sign..imag..")")

is it possible to message you direct? I'd really like to get this working.

local temp = tonumber(sign..imag)
should do..

P.S I really have no idea whether this would work or not...So don't blame me if it doesn't :)

I'm happy to try!
sorry I mean what is...

imag = loadstring("return tonumber("..sign..imag..")")

@Dax
I suggested the modification to that complex numbers in github and the author himself did a modification to eliminate loadstring..
https://github.com/davidm/lua-matrix/commit/8dd7aa293fdaaf5808736214a06ff121121300d5
Wonderful guy! :D
Hope that works!

brilliant - well done mate!

views:1762 update:2011/12/30 9:10:41
corona forums © 2003-2011