Re: Meaning of memset
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Mon, 05 Nov 2007 20:28:14 +0000
James Kuyper <jameskuyper@xxxxxxxxxxx> writes:
Ark Khasin wrote:
...
Is it so that a consensus emerges that ^ | & on negative numbers
depend
I can't speak for the consensus; this is just my understanding of what
the standard says. In many cases my understanding differs distinctly
from the consensus understanding.
on representation (or, to tell the truth, act on representations)
and so are implementation-defined (although only 3 ways to implement
are recognized)?
Those operators don't act on the representations of objects; otherwise
cases like
x += (a+1) | (b-2);
You have written a correct statement because, of course, a+1 is not an
object. The question is, does '(a+1) | (b-2)' depend (or act) on the
representation of 'a+1' and 'b-2' and I'd say it does.
Section 6.2.6 is called "Representations of types" (not objects) and
6.2.6.1 p4 takes some pains to define a new term -- the "object
representation" -- which is not quite the same thing as the
representation of the type.
I don't want to suggest that | operates on padding bits. I don't
think one can determine that either way, but it seems to be pushing the
meaning of representation to its limits (and beyond that used in the
standard) to say that |, &, and ^ act on the value not the
representation.
would be undefined. The way that they operate on or generate negative
values must, however, be consistent with whichever of 3 permitted ways
of handling the sign bits that the implementation chose for the
relevant type.
These "permitted ways" are described in the section called
"Representation of types". Your sentence would be simpler if you had
said that the bits they operate on (and the meaning of the bits that
are produced) are determined by the representation used for signed
integer types.
It is possible to define the result of | on signed types by talking
only about the value of the operands, but it is complicated to do so
and the standard clearly distinguishes between the terms
"representation" and "object representation" so that there is simple
way to understand the operation. The standard uses only few words to
define | (and the others) because the term "corresponding bits" is
clearly intended to refer back to the bits used to represent the
value as described in 6.2.6.
I see no way for those operators to operate on the
padding bits in any sense that is meaningful within the context of the
standard.
I agree, but padding bits are only one part of the representation of
the type.
--
Ben.
.
- Follow-Ups:
- Re: Meaning of memset
- From: James Kuyper
- Re: Meaning of memset
- References:
- Assigning values to char arrays
- From: emyl
- Re: Assigning values to char arrays
- From: Richard Heathfield
- Re: Assigning values to char arrays
- From: somenath
- Re: Assigning values to char arrays
- From: Richard Heathfield
- Re: Assigning values to char arrays
- From: somenath
- Re: Assigning values to char arrays
- From: Richard Heathfield
- Meaning of memset (Was: Re: Assigning values to char arrays)
- From: Ark Khasin
- Re: Meaning of memset (Was: Re: Assigning values to char arrays)
- From: Ben Bacarisse
- Re: Meaning of memset (Was: Re: Assigning values to char arrays)
- From: Ark Khasin
- Re: Meaning of memset (Was: Re: Assigning values to char arrays)
- From: James Kuyper
- Re: Meaning of memset
- From: Ben Bacarisse
- Re: Meaning of memset
- From: James Kuyper
- Re: Meaning of memset
- From: Ben Bacarisse
- Re: Meaning of memset
- From: Ark Khasin
- Re: Meaning of memset
- From: James Kuyper
- Assigning values to char arrays
- Prev by Date: Re: Absense of bool
- Next by Date: Re: Bug/Gross InEfficiency in HeathField's fgetline program
- Previous by thread: Re: Meaning of memset
- Next by thread: Re: Meaning of memset
- Index(es):
Relevant Pages
|