lua-users home
lua-l archive

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


On Wed, May 15, 2019 at 12:56 PM Francisco Olarte <folarte@peoplecall.com> wrote:
> However, the way the spec is written,
...
I've read the spec, but, when he said " then it computes the
bit-inversion (i.e. its a simple arithmetic addition: substract the
value from the maximum of its input type and adds the minimum of that
type); as this input type is an int, , it returns an int equal to
(INTMAX - 0 + INTMIN)." it seemed ( and still seems to me ) he was
trying to redefine not arithmetically.

Ah, okay, that makes more sense. That's what I meant about the way it was phrased -- I thought he meant that's what the type coercion was doing (it's not).

As a description of the arithmetic effect of the ~ operator... *crunches some numbers* It works for 1's complement and 2's complement for both signed and unsigned, but it only works for unsigned on a sign-magnitude system. (And INTMIN for an unsigned type is, obviously, 0.) This is fine according to the C spec because the spec only carries demands on the arithmetic behavior of bitwise operators for unsigned operations, but it does mean you can't quite say that _expression_ is universally true across all conformant C implementations.

/s/ Adam