[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: boolean operators
- From: "Grellier, Thierry" <t-grellier@...>
- Date: Wed, 27 Sep 2006 11:10:59 +0200
Why not \ instead of // ?
From: email@example.com [mailto:firstname.lastname@example.org] On Behalf Of Rici Lake
Sent: Friday, September 22, 2006 1:53 AM
To: Lua list
Subject: Re: boolean operators
On 21-Sep-06, at 5:01 PM, David Jones wrote:
> Le 21 Sep 2006 à 21:28, Rici Lake a écrit :
>> Regardless of bitwise operators, I would vote strongly in favour
>> of an integer divide operator, to go along with 5.1's remainder (%)
>> operator. At the risk of alienating C++ programmers, I'd suggest
>> that integer divide be spelled "//". It's precise definition
>> would be: a // b ==> (a - a%b) / b
> Lispers would ask for floor, ceiling, truncate, and round as well.
> Funny how no-one ever wants round-away-from 0, could be called
> "inflate" perhaps?
In Lua, % is defined as "the remainder of the division that rounds the
quotient towards minus infinity".
floor: a // 1
ceiling: -(a // -1)
round: (a + .5) // 1
(I don't have a good one for truncate, without using abs and sign).
Still, I think // is pretty generally useful.