[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Possible improvements to the LNUM patch?
- From: Ralph Hempel <rhempel@...>
- Date: Tue, 15 Apr 2008 08:31:21 -0400
Aladdin Lampé wrote:
Indeed, the calculations (Lua scripts) are provided by the users of my
application, and I don't feel like explaining in the documentation that
it is forbidden to test whether 1 < decNumber.tonumber("1.5") and that
what they should write instead is: decNumber.tonumber("1") <
decNumber.tonumber("1.5")...
Users of my original integrated float/integer complained about the
same thing.
See my earlier post on implementing an automatic "cast" or conversion
from Lua_Number to your userdata type in the implementation of
comparison operators for your userdata.
Here's how it looks now in pbLua
f = nxt.float() -- No parameters makes 0.0
i = 3
j = "5"
> =f<i
true
> =i<f
false
> j<i
false
The comparison will try to convert a number (or string if possible) to
a float before comparing with the float userdata.
You will run into a range issue at some point....
Ralph