473,800 Members | 3,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Classification of arithmetic types

As Richard Bos rightly pointed out, I had left in my classification
of types the C99 types Complex and boolean. Here is a new
classification. Those are not mentioned in the classification
of Plauger and Brody, probably because their work predates
C99. Since there are no examples of this in the literature
(known to me) please take a look.

Thanks
3.1.1 Arithmetic types
3.1.1.1 Integer types
3.1.1.1.1 Specific integer types
3.1.1.1.1.1 boolean type
3.1.1.1.1.2 char (signed/unsigned)
3.1.1.1.1.3 short (signed unsigned)
3.1.1.1.1.4 int (signed/unsigned)
3.1.1.1.1.5 long (signed/unsigned)
3.1.1.1.1.6 long long (signed/unsigned)
3.1.1.1.2 Bitfields (signed/unsigned)
3.1.1.1.3 Enumeration types
3.1.1.2 Floating types
3.1.1.2.1 Real types
3.1.1.2.1.1 float
3.1.1.2.1.2 double
3.1.1.2.1.3 long double
3.1.1.2.4 Complex types
3.1.1.2.4.1 float Complex
3.1.1.2.4.2 double Complex
3.1.1.2.4.2 long double Complex

I would define arithmetic types as those that define the 4 operations.
This distiguishes them from pointer types where addition and
subtraction are defined but not multiplication/division.

Is that correct?

jacob
Dec 11 '06
27 2058
Richard Bos wrote:
jacob navia <ja***@jacob.re mcomp.frwrote:
.... snip ...
>>
As far as I understood this stuff, all those are defined in terms
of one of the primitive types in the enumeration above.

Not necessarily. For example, on historic implementations , time_t
was often larger than a single long, and was therefore a struct.
Ditto for, e.g., fpos_t. The point about such types is that they
may be one specific primitive type on any particular implementation,
but to the wise C programmer they must remain abstract types. As
such, they deserve discussion.
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 arithmetical types are extremely primitive, in that they
cannot precisely specify the domain. They tend to simply specify a
maximum (and minimum) value, which is pre-defined. This is one of
the primary causes of invalid indices.

Even an enum cannot specify the precise validity range in C. You
can catch unenumerated values with a switch statement having a
default case.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
Dec 11 '06 #21
Eric Sosman wrote:
>
.... snip ...
>
The Standard disagrees with you (6.2.5/14). `char' is a type unto
itself, distinct from both `signed char' and `unsigned char'.
`int' and `short' are distinct types even when both are 16 bits
wide; `int' and `long' are distinct even when both are 32 bits
wide; `double' and `long double' are distinct even when both are
IEEE double-precision numbers. Representation and behavior are
not the sole ingredients of "type."
Reminds me of the arguments about type compatibility during Pascal
standardization . It eventually became identical type names, rather
than composition.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
Dec 11 '06 #22
CBFalconer wrote:
>
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.

--
Eric Sosman
es*****@acm-dot-org.invalid
Dec 11 '06 #23
Eric Sosman <es*****@acm-dot-org.invalidwrit es:
[...]
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>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 11 '06 #24
jacob navia <ja***@jacob.re mcomp.frwrote:
Keith Thompson a écrit :
jacob navia <ja***@jacob.re mcomp.frwrites:
>I would define arithmetic types as those that define the 4 operations.
This distiguishes them from pointer types where addition and
subtraction are defined but not multiplication/division.

Is that correct?
You don't get to define "arithmetic types". The term is defined in
C99 6.2.5p18. (I believe your definition happens to match the
standard's definition.)

Read C99 6.2.5 before you speculate.

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
Dec 12 '06 #25
Richard Bos a écrit :
jacob navia <ja***@jacob.re mcomp.frwrote:

>>Keith Thompson a écrit :
>>>jacob navia <ja***@jacob.re mcomp.frwrites:
I would define arithmetic types as those that define the 4 operations.
This distiguishes them from pointer types where addition and
subtracti on are defined but not multiplication/division.

Is that correct?

You don't get to define "arithmetic types". The term is defined in
C99 6.2.5p18. (I believe your definition happens to match the
standard's definition.)

Read C99 6.2.5 before you speculate.

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
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!
Dec 12 '06 #26
jacob navia wrote:
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:".

--
Chris "Perikles triumphant" Dollin
The "good old days" used to be much better.

Dec 12 '06 #27
jacob navia <ja***@jacob.re mcomp.frwrote:
Richard Bos a écrit :
jacob navia <ja***@jacob.re mcomp.frwrote:
>Keith Thompson a écrit :

jacob navia <ja***@jacob.re mcomp.frwrites:

I would define arithmetic types as those that define the 4 operations.
This distiguishes them from pointer types where addition and
subtractio n are defined but not multiplication/division.

Is that correct?

You don't get to define "arithmetic types". The term is defined in
C99 6.2.5p18. (I believe your definition happens to match the
standard's definition.)

Read C99 6.2.5 before you speculate.

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.

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
Dec 14 '06 #28

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2849
by: Lionel B | last post by:
Greetings, I am trying to implement "element-wise" arithmetic operators for a class along the following lines (this is a simplified example): // ----- BEGIN CODE ----- struct X { int a,b;
16
5145
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. And K&R2 mentions "signed extension" everywhere. Reading some old clc posts, I've beginning to realize that these books are over-generalizing the topic. I am just wondering what the difference between the following pairs of terms are: 1)...
4
1556
by: PDHB | last post by:
I'm sorry, but this is just the height of stupidity. I love the dot net framework. It has actually been sufficient to convert an anti-microsoft extremist (myself) to the windows camp. But not having numerical value types inherit from an interface to allow for arithmetic in generics, or in some other way allow arithmetic in generics without a performance killing or ugly work around is just the epitomy of idiocy. Yes, microsoft today is...
2
5125
by: Frederick Gotham | last post by:
I just want to clarify my understanding of arithmetic and comparison between two different integer types. Phase (1): Integer Promotion ---------- All of the following types always get promoted to "signed int": signed char
26
3065
by: Bill Reid | last post by:
Bear with me, as I am not a "professional" programmer, but I was working on part of program that reads parts of four text files into a buffer which I re-allocate the size as I read each file. I read some of the items from the bottom up of the buffer, and some from the top down, moving the bottom items back to the new re-allocated bottom on every file read. Then when I've read all four files, I sort the top and bottom items separately...
6
13832
by: sarathy | last post by:
Hi, What is integer promotion? How is it different from arithmetic conversion? Regards, Sarathy
6
1645
by: Grant Robertson | last post by:
I am interested in including classification info in metadata. I am aware of the Dublin Core and XMP. However, neither of these appear to specify exactly how the classification data should be formatted within the element. I am interested in any standardized formats for expressing Dewey Decimal System - DDS, Library of Congress Classification - LCC, Cutter Expansive Classification, Universal Decimal Classification - UDC, Colon Notation...
4
1945
by: Evan Klitzke | last post by:
Hi all, What frameworks are there available for doing pattern classification? I'm generally interested in the problem of mapping some sort of input to one or more categories. For example, I want to be able to solve problems like taking text and applying one or more tags to it like "romance", "horror", "poetry", etc. This isn't really my research specialty, but my understanding is that Bayesian classifiers are generally used for problems...
0
9689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7573
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2942
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.