operation "//" - idiv-3Jlou_nTu4- User Offline 04.12.18 07:44:50 am I didn't find integer division in cs2d lua. And forced use this code to do it 123function idiv(value1, value2) 	return math.floor(value1 / value2 + 0.5) end Maybe in cs2d an operation is described that performs it quickly such us: value1//value2?
Re: operation "//" - idivBowlinghead User Offline 04.12.18 05:40:09 pm http://www.cs2d.com/help.php there is the whole cs2d code related documentary. There´s nothing like that
Re: operation "//" - idivohaz User Offline 04.12.18 11:04:16 pm @ Bowlinghead: That's only the CS2D part. The Lua in CS2D however contains all the Lua commands available. There actually is a // operator in Lua. Have you tried it? Maybe it's just in a newer version, then @ DC would have to update the Lua version.
Re: operation "//" - idivVADemon User Offline 05.12.18 04:14:09 pm Integer division was added in Lua 5.3 because it also added a seamless number subtype: integer (numbers ending with .0 like 1.0) You can simulate // using this: 1math.floor(x/y) The number is always rounded down. https://www.lua.org/cgi-bin/demo : 12print(1//2, math.floor(1/2)) print(-1//2, math.floor(-1/2)) The real advantage of integer division is that it's faster, not because you lose the fractional part. You always had the math.floor (round down, towards -∞) / math.ceil (round up, towards +∞) option for that.