lua-users home
lua-l archive

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


> >From page 18 of a PDF at http://www.lua.org/wshop14/Ierusalimschy.pdf,
> Professor Ierusalimschy states: "Integer division converts operands to
> integers and does an integer division."
> 
> However, the following examples using Lua 5.3.1 interactively, show that
> either there is something about this I don't understand, or the preceding
> statement is not correct:
> 
> C:\>lua
> Lua 5.3.1  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> 
> > 1//1
> 1
> > 3.0//2
> 1.0
> 
> > 3.0 // 3.0
> 1.0
> > 3 // 2
> 1
> > 2.0//2
> 1.0
> > 2 // 2.0
> 1.0
> > 6.0 // 1
> 6.0
> 
> These examples show that the operands of // are *not* converted to integer,
> and in the case of non-integer operands, // does not do an integer division
> unless both operands are in integer form.
> 
> Am I just misunderstanding something basic, or is this actually a bug?

That talk was given before Lua 5.3 was released, and some details in
those slides were outdated.  Between the talk and the release, the
operation changed from "integer division" to "floor division".

-- Roberto