lua-users home
lua-l archive

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


On Wed, Jun 4, 2014 at 9:31 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
Am 04.06.2014 18:48 schröbte Andrew Starks:

print(math.min(1,2), math.max(1,2))
--1.0, 2.0

I would have expected integers.

It's the same with strings:

    print(type(math.max("1", "2")))


-Andrew


Philipp





I'd be very surprised if math.max(a, b) behaved any differently from:
function max(a, b)
    if a > b then return a
    else return b
    end
end

i.e. no changing of types involved (and for that matter, not caring at all about types, as long as the operands have > defined).

(Of course it's slightly trickier since math.max() accepts any number of values except zero, but the principle is the same.)

--
Sent from my Game Boy.