Classification of arithmetic types

K

Keith Thompson

P.J. Plauger said:
The proper term, instead of "characteristics", is "representation".
It is often true in C that two types have the same representation
but are nevertheless considered by the compiler to be distinct
types. char/signed char or char/unsigned char is just one of these
pairs.
[...]

I used the more general term "characteristics" because there's more to
it than just the representation. Plain char and (signed|unsigned)
char have the same representation, alignment, minimum and maximum
valiues, and probably some other things I haven't thought of. Or are
all those things considered part of the "representation"?

Plain char and (signed|unsigned) char are identical in all respects
*except* that they have different names and are distinct types.
 
E

Eric Sosman

CBFalconer said:
As far as I am concerned, a 'type' means specifying the domain of
allowable values, together with a set of operations on those
values. [...]

C's "type" is a little stronger/richer/fussier than that.
For example, `char' and `signed char' and `unsigned char' are
three distinct types, even though only two sets of values and
operations are evident. `double' and `long double' sometimes
share the same set of values and operations, yet the types
are distinct. The types

struct zaphod { int x; };
struct beeble { int x; };

offer the same set of values and support the same operations,
and yet are two distinct (and incompatible) types.
 
K

Keith Thompson

Eric Sosman said:
The types

struct zaphod { int x; };
struct beeble { int x; };

offer the same set of values and support the same operations,
and yet are two distinct (and incompatible) types.

<quibble>
They don't support the same operations, merely identical operations
(or perhaps isomorphic would be a better word). For example, struct
zaphod does not provide the operation of assigning to a struct beeble,
or vice versa.
</quibble>
 
R

Richard Bos

jacob navia said:
Keith Thompson a écrit :

The standard just says:

"Integer and floating types are collectively called arithmetic types."

This definition is just an enumeration, not a functional
definition, that I would prefer.

What you prefer is really not important. _This_ is how the Standard
defines arithmetic types. If you want another definition, call it
something else. Don't behave as a wannabe Microsoft.

Richard
 
J

jacob navia

Richard Bos a écrit :
What you prefer is really not important. _This_ is how the Standard
defines arithmetic types. If you want another definition, call it
something else. Don't behave as a wannabe Microsoft.

Richard

Look I am writing a tutorial, not a commentary to the Bible. The
definition of the standard just says:

The arithmetic types are these.

I want to define them in terms of manipulation, i.e. in terms
of their functionality: The arithmetic types have these operations in
common.

Besides it is not evident what Microsoft has to do here. I am in no
way implying that my humble tutorial is a standard for anything!
 
C

Chris Dollin

jacob said:
Look I am writing a tutorial, not a commentary to the Bible. The
definition of the standard just says:

The arithmetic types are these.

I want to define them in terms of manipulation, i.e. in terms
of their functionality: The arithmetic types have these operations in
common.

Do both. Say "The arithmetic types are <whatever>, and have these
operations in common:".
 
R

Richard Bos

jacob navia said:
Richard Bos a écrit :

Look I am writing a tutorial, not a commentary to the Bible.

All the more reason to be precise, and not confuse the learners.
The definition of the standard just says:

The arithmetic types are these.

I want to define them in terms of manipulation,

You don't get to define what the Standard already has defined for you.
Again: if you want something defined by those operations, _call it
something else_. You can then point out that, _as far as you can grasp_,
that comes to the same thing as the Standard definition of arithmetic
types.

Richard
 

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,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top