Bit mask

R

Richard Bos

Alexander Bartolich said:
begin followup to Christopher Benson-Manica:

Well, on a machine running trinary logic ... perhaps using three
charge states of an atom ... where the decimal number '7' is
represented by the digits '21' ... well, how the **** is bitwise
negation meant to work there?

Slowly. But it must, because the Standard requires it.

If you ever find a ternary computer with a C compiler, warn me, I could
do with a laugh.

Richard
 
P

Peter Nilsson

pete said:
He may have been refering to negative zero, instead of padding bits.

In C99 there's only 3 formats for representing negative integers,
but in C89, the representation for negative integer values
is only specified in broad terms relating to sign and value bits,
which would allow an implementation to define any particular
negative integer value representation, as negative zero.

I'm not with you! How is ~7 a negative zero in C89? As I understood
it, there were no trap representations in C89, irrespective of the
representation chosen.
 
P

Peter Nilsson

pete said:
The C89 standard does not specify the representation
for the magnitudes of negative integer values.

But the responses in DR#069, although rather cryptic (both the questions and
responses are rather carelessly mislabled), seems to rule out the
possibility of ~7 being a 'negative zero'.

Given the committee's interpretation of "pure binary numeration system", I'm
not sure what other systems are actually allowed apart from the common 3
(padding bits and 'holes' notwithstanding).

That said, I'm more than happy to stick to the golden rule of not using
signed integers for bit manipulations whenever the sign bit is, or could
become, 1. :)
 
P

pete

Peter said:
But the responses in DR#069,
although rather cryptic (both the questions and
responses are rather carelessly mislabled), seems to rule out the
possibility of ~7 being a 'negative zero'.

I don't see anything there which would prohibit
1111 1111 1111 1000 from representing negative zero.
Given the committee's interpretation of
"pure binary numeration system", I'm
not sure what other systems are actually
allowed apart from the common 3
(padding bits and 'holes' notwithstanding).

The systems which are allowed in C89 are not specified by name,
so any system which uses the sign bit for negative values
followed by any systematic representation of the magnitudes,
would have been valid in C89.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,174
Latest member
BlissKetoACV
Top