lua-users home
lua-l archive

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


Здравствуйте, Roberto.

Вы писали 18 декабря 2014 г., 16:40:23:

>> > As this point has come up several times, I have a quick quiz for this
>> > list. Without running the code, what are the results of the following
>> > expressions in Lua 5.2?
>> >
>> >   string.rep("a", 2.7)
>> >   string.format("%d", 2.7)
>> >   string.rep("a", 2.3)
>> >   string.format("%d", 2.3)
>> >

>> Undefined, Undefined, Undefined, Undefined, or with GCC, "aaa", "3",
>> "aa", "2" (pretty sure GCC rounds properly? I may be wrong)
>> (Soni)

>> About the quiz, in version 5.2, I believe that all values are considered
>> equal to 2.
>> (Charles)

>> IIRC, in practice, lua always rounds down. so:
>> aa
>> 2
>> aa
>> 2
> (Daurnimator)

> "Undefined" is correct according to the manual, but (unlike 5.3) the
> implementation thinks otherwise. And none of these answers match what my
> machine (an ordinary Pentium/Linux) does.  Anyone else want to try an
> answer?

WinXP/MSVC 2010

Lua 5.1/5.2
aaa
2
aa
2

LuaJIT 2.1.0-alpha
aa
2
aa
2

LuaJIT 2.0.1
aaa
3
aa
2





--
С уважением,
 Alexeymelnichuck                          mailto:alexeymelnichuck@gmail.com


---
Это сообщение проверено на вирусы антивирусом Avast.
http://www.avast.com