[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Problem with 'lt' event in MAPM, Lua 4.0.
- From: "Alexey Yutkin" <yutkin@...>
- Date: Wed, 9 Oct 2002 12:29:31 -0800
Problem with 'lt' event in MAPM, Lua 4.0.
-------------------------------------------------------
MAPM - A Portable Arbitrary Precision Math Library
-------------------------------------------------------
Compare function, C wrap:
static int Bcompare(lua_State *L)
{
M_APM a=Bget(L,1);
M_APM b=Bget(L,2);
lua_pushnumber(L, m_apm_compare(a,b));
return 1;
}
-------------------------------------------------------
'lt' event definition:
local TAG=tag(Bnumber())
settagmethod( TAG,"lt", function (a,b)
local r = Bcompare(a,b)
if r== -1 then return 1 end
return nil end
)
simple test:
-------------------------------------------------------
code | output
a = Bnumber(2) |
b = Bnumber(2) |
print(Bcompare(a,b)) | 0
print(a,b, a<b) | 2.0 2.0 nil -- Ok
print(a,b, a>b) | 2.0 2.0 nil -- Ok
print(a,b, a<=b) | 2.0 2.0 1 -- Ok
print(a,b, a>=b) | 2.0 2.0 1 -- Ok
print(a,b, a==b) | 2.0 2.0 nil -- Error
print(a,b, a~=b) | 2.0 2.0 1 -- Error
-------------------------------------------------------
How I can solve this problem?
Best regards,
-- Alexey Yutkin.