lua-users home
lua-l archive

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

Thursday, September 28, 2006, 5:54:39 PM, Nick Gammon wrote:

> On 28/09/2006, at 9:43 PM, David Jones wrote:

>> I think you could argue that one should have unary plus on grounds
>> of symmetry. :)

> I agree with this, it seems strange you can do:

> a = -5

> but not:

> a = +5

>> I don't think it would be a no-op, it should coerce its operand to
>> a number, just like unary minus does:

decNumber has a unary plus; it isn't really a no-op since it applies
the thread's current rounding/precision context to the operation, e.g.,

print (decNumber.version)
ctx = decNumber.getcontext()
local x = decNumber.tonumber("123.456789")
print (x)
x = x:plus()
print (x)


Lua Decimal Number Module version 17 for Lua 5.1 with decNumber 3.36


Doug Currie
Londonderry, NH