|
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) / bLispers 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".
Consequently: 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.