Date: Thu, 02 Apr 2026 09:24:34 -0700
On Thursday, 2 April 2026 01:32:56 Pacific Daylight Time Jan Schultke via Std-
Proposals wrote:
> - Separate the sign bit from the rest of the representation. This makes
> negation and absolutes incredibly cheap, regardless of the dynamic size
> of the integer. It also makes it cheap to query whether the integer is
> negative.
I'm curious why you'd want a sign-magnitude implementation. It seems to me
that adding numbers is a far more common operation than negating them.
Subtractions don't need to be implemented as negation plus addition.
I also don't see how that implies querying the sign wouldn't be cheap. It's
always O(1) anyway. If the worry is that of dereferencing the pointer to non-
short object, you can always do double book-keeping of the sign bit.
Proposals wrote:
> - Separate the sign bit from the rest of the representation. This makes
> negation and absolutes incredibly cheap, regardless of the dynamic size
> of the integer. It also makes it cheap to query whether the integer is
> negative.
I'm curious why you'd want a sign-magnitude implementation. It seems to me
that adding numbers is a far more common operation than negating them.
Subtractions don't need to be implemented as negation plus addition.
I also don't see how that implies querying the sign wouldn't be cheap. It's
always O(1) anyway. If the worry is that of dereferencing the pointer to non-
short object, you can always do double book-keeping of the sign bit.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-04-02 16:24:38
