473,766 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

32 or 64 bit processor info in C

Hello,

Is there a way in C to get information at runtime if a processor is 32
or 64 bit?

Cheers,

Broeisi

Apr 10 '07
168 7290
Army1987 wrote, On 14/04/07 12:20:
"Malcolm McLean" <re*******@btin ternet.comha scritto nel messaggio
news:iN******** *************** *******@bt.com. ..
<snip>
>Virtually every integer, pace Flash Gordon, is used as an array index or
in intermediate calculations to derive indices. But since size_t is
unsigned, awkward to read, and most numbers are much less than 2 billion,
people won't use it consistently.

If the problem is that size_t is unsigned, use ptrdiff_t. But, first, ask
yourself wheter you *really* need it.
That reminds me, you also have intptr_t and uintptr_t which, if present,
are guaranteed to be large enough to hold and pointer, so by inference
are going to be as large as the address bus (unless pointers are
narrower than the address bus).
--
Flash Gordon
Apr 14 '07 #81
Malcolm McLean wrote, On 14/04/07 09:09:
>
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:tn******** ***@news.flash-gordon.me.uk...
>Malcolm McLean wrote, On 12/04/07 22:03:
>>>
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:en****** ******@news.fla sh-gordon.me.uk...
Malcolm McLean wrote, On 12/04/07 08:07:

<snip>
>>Since most integers are used in array indexes, i.e.
count things in the computer's memory, that tells you what the
natural integer size is on any particualr machine.

You've claimed that before and failed to support it. In over 20
years of professional programming most of my use of integers has not
had anything to do with array indexes. On the stuff I currently work
on we use integers for money, for example, and I've never needed to
use cost as an index in to an array!

I posted a study for you. You do need a little bit of insight to
intepret data, unless you have the resources to study everything by
brute force.

I explained why the study did not prove the point. Amongst other
things, it explicitly excluded major classes of code, such as server
applications .
This is an important point.
Finding an objection to evidence doesn't make that evidence disappear,
If the objections are valid then it means the evidence is not relevant.
or turn the opposite case into a "mere assertion" position.
If you have no evidence for which there are not valid objections then
your position is merely your opinion.
You seldom have exactly the evidence you would like.
That is why people conduct studdies. Some times those studdies can be
done by taking the raw data from a number of other studdies, but you
have to design your study first then go and collect the data from the
other studies.
For instance the
example I gave was Java, not C, it was from a selection of about ten
applications, and the study wasn't designed to show what I asserted, the
conclusion had to be derived by looking at the evidence with some
assumptions.
Assumptions which have to be justified, especially if challenged. You
have not given any justification for your assumptions (which you did not
state) or explanation of why my challenges are wrong.
However whilst your objections were legitimate, in fact the idea that
Java code is very different from C code in its use of arrays, that
server applications use arrays in a very different way from most general
applications, that array access instructions don't bear a very tight
relationship to index calculations, and so on, aren't all that
plausible.
I gave specific reasons why certain classes of applications do a lot of
integer work that is not to do with indexing. Here is another, a number
of the SQL data types are either integer types (which will be impleneted
as integer types) or scaled integer types (which will be implemented as
integer types with the scaling stored as part of the column definition.
The manipulation of those integer types will be on the basis of SQL
queries, summing costs etc. On financial applications, such as Sun
Financials, they make use of such types a lot, and hardly any use of
arrays. I suspect that there is a LOT of financial SW out there where
they do not want to use floating point for numbers because the law does
not permit them to have rounding errors (or specifies specific rounding
which you won't be able to guarantee with floating point numbers).

Probable most "indexing" done by a database is indexing in to a file,
not memory, so by that argument we need int to be large enough to store
the size of the largest table that might be required, and that is
independent of the processor!
You would need to do a proper study to establish the matter
beyond all possible doubt.
You would need to do rather more than look at one very biased sample to
have any significant evidence.
However do you think I could get a research
grant for people to sit tagging up C code to establish how much indexing
is done? It would be expensive and wouldn't tell us very much that we
don't know already.
So far the only person to jump in on either side is Richard Heathfield,
and he seems to take the opposing view. So another biased sampling shows
that most C developers either have no opinion on the subject or disagree
with you.
Most scientific studies have tight cost limits and
aren't as rigorous as we would like. That doesn't mean that they are
useless.
True, but they have vastly more rigour than looking at a sample that
says it was biased and then using the data for something the collection
was not designed for.
You'll often come across this fallacy in a much more gross way than you
have made it. I can find an objection to the evidence, therefore it
disappears.
If a sample can be shown to be biased for the use it is being put to
then you cannot use it on its own as evidence for your point. If you
collect data from enough other studdies with different biases and can
show they cancel out, or you can come up with a way to counteract the
bias (with evidence supporting your method) then you can use it.

Note that I do not claim to know whether overall integer types are used
more for indexing and related operations or for other purposes. I only
claim that my experience contradicts it and that you have no significant
evidence to support your personal opinion.
--
Flash Gordon
Apr 14 '07 #82
Malcolm McLean wrote, On 14/04/07 08:57:
"Keith Thompson" <ks***@mib.orgw rote in message
news:ln******** ****@nuthaus.mi b.org...
>"Malcolm McLean" <re*******@btin ternet.comwrite s:
C has had multiple sizes of integers since before K&R1. If you want a
type that's at least 32 bits, you can easily find one. If you want a
type that's at least 64 bits, you can *probably* find one, typically
called "long long" (standard in C99, a common extension in pre-C99
implementation s).

Your opinion that type int should be 64 bits is, I suppose, perfectly
valid, but the vast majority of C programmers (everyone except you, as
far as I can tell) don't share that opinion. C's type system isn't
perfect, but it is reasonably consistent, and it works.
I'm not saying you're wrong, merely that the language isn't going to
be changed in the way you want it to be changed. You can accept that,
or you can find or invent another language. In the meantime, of
course, you're free to advocate the changes you want, but you need to
be aware that it would be a major change, and that it would *not* be
in keeping with the language as it currently exists, and has existed
for at least 20 years.
I want a type called "int" and signed that is the size of the address
bus.
C has NEVER had that as the definition of what an int should be.
To be fernickety about it it really needs an extra bit, but in
practise if you need over half the address space for a single array then
you can code access to it specially.
That has been the convention until now.
No it has not. It has already been pointed out that Intel have done
processors with 24 bit address busses where the compilers provided
either 16 or 32 bit ints. Check up on the x86 series of processors, they
are fairly common.
The proposal is to change it, to
make int no longer the natural integer size for the machine.
There is no such processors. All the processors around for which
compilers are providing a 32 bit int can natively and naturally handle
32 bit ints.
The problem with size_t was that the implications weren't thought
through. I am sure the committee thought that they were adding a minor
patch to malloc() and documenting variables that hold sizes of memory.
They didn't realise the implications. The problem is that if int is 32
bits and memory is 64 bits, then every array index to an arbitrary array
needs to be a size_t. Virtually every integer, pace Flash Gordon, is
used as an array index or in intermediate calculations to derive
indices.
I'm not the only person doing financial SW. There are lots of other
people doing image processing and avionics SW.
But since size_t is unsigned,
When have you needed a negative amount of memory or needed to index
before the start of an array?
awkward to read,
That is a matter of opinion.
and most
numbers are much less than 2 billion,
Most number used may be, but there is significant demand for larger
numbers, such as in calculating the tax of a company that turns over
more than 20,000,000 of the local currency (assuming something like the
UKP or USD when you have 100 cents/pennies to the dollar/pound). In some
currencies it is even easier to need numbers above 2 billion! Note I
only say significant demand, not that this is the majority usage.
people won't use it consistently.
That's true of almost everything in all languages.
A type is a standard for passing data between functions.
It is also useful for doing the actual work! In fact, if it is
So we'll have
the two plugs problem. It will seriously impact the reusability of C code.
No, code that uses it properly is easily reusable. Code that does not
use it, or uses it incorrectly, is harder to reuse, but that is the same
for everything.
If int is 64 bits on 64-bit machines size_t will gradually fade
away.
Not in properly written code, because it is for a different purpose.
I'm not proposing removing the symbol from C code just yet, merely
suggesting that it isn't used except as a fix to library functions, or
in special cases.
Then don't use it, no one is forcing you to.
Eventually we will return sizeof() to generating an
int,
Since it has not changed yet, despite this "problem" having occured
before in the move from "16 bit" to "32 bit" processors, I doubt it will
change in the future. Unless you find a way of creating objects with a
negative size, that is.
and remove it from the string functions, so it will survive merely
as a fossil in malloc().
I doubt that will happen either, see above.
C does not have fixed size basic types. Rightly or wrongly. By
making int a fixed size of 32 bits compiler vendors are the ones making
the change, not me.
No, since it is the Unix standard and the OS developers that generally
specify the ABI. In any case, as stated else-thread, the 64 bit
processors in general (the Cray is an exception) can handle 32 bit
integers as naturally as 64 bit ones and using 32 bit integers can give
a significant performance boost by halving the amount of traffic between
the fast processor and the slow memory.
As 64 bit machines hit the mass market,
Too late, they have already hit it some time back, and the decisions
were made a LONG time before that.
we have a
brief chance to save our language from ANSI doing to C what they did to
C++.
The language is fine as it is, there is nothing to save it from. Of
course, if you do not like the language defined a few decades ago feel
free to use a different language.
--
Flash Gordon
Apr 14 '07 #83
Malcolm McLean wrote:
>
I want a type called "int" and signed that is the size of the address
bus.
That's nice. I want a strawberry shortcake.

More to the point, what extensions do you propose to C to
make "the size of the address bus" measurable? How can C even
detect the existence of an "address bus," much less measure its
size, or its temperature and mass for that matter?

Well, maybe we don't need to have C measure this elusive
quantity; we can follow the tradition of some other hard-to-
measure values and simply supply them as implementation-provided
macros, the same way we do with things like FLT_RADIX. Fine, but
where does that leave your precious 64-bit int? What size int do
you want on a machine with 64-bit virtual addresses but, say, a
48-bit physical address?
That has been the convention until now. The proposal is to change it, to
make int no longer the natural integer size for the machine.
Width of int == width of address bus has *never* been the
convention. On some machines -- but by no means all -- the
relation did happen to hold, but that was just coincidence. I
challenge you to find one, even one reference to "width of
address bus" in K&R, either original or revamped.
The problem with size_t was that the implications weren't thought
through. I am sure the committee thought that they were adding a minor
patch to malloc() and documenting variables that hold sizes of memory.
They didn't realise the implications. The problem is that if int is 32
bits and memory is 64 bits, then every array index to an arbitrary array
needs to be a size_t.
And why, precisely, is that a problem?
Virtually every integer, pace Flash Gordon, is
used as an array index or in intermediate calculations to derive
indices.
Proof by repetition. If you say it even louder next time,
it will be even truer, right?
But since size_t is unsigned, awkward to read, and most
numbers are much less than 2 billion, people won't use it consistently.
Ah, *that's* why size_t is a problem: Because "programmer s"
who won't learn the language write bad code! So you're arguing
that the language design should be driven by the needs of the
ignorant and lazy, to the detriment of the diligent and able?
Recommended reading: "With Folded Hands" by Jack Williamson.

--
Er*********@sun .com
Apr 14 '07 #84

"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:7l******** ****@news.flash-gordon.me.uk...
Malcolm McLean wrote, On 14/04/07 09:09:
>>
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:tn******* ****@news.flash-gordon.me.uk...
>>Malcolm McLean wrote, On 12/04/07 22:03:

"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:en***** *******@news.fl ash-gordon.me.uk...
Malcolm McLean wrote, On 12/04/07 08:07:

<snip>

Since most integers are used in array indexes, i.e.
>count things in the computer's memory, that tells you what the
>natural integer size is on any particualr machine.
>
You've claimed that before and failed to support it. In over 20 years
of professional programming most of my use of integers has not had
anything to do with array indexes. On the stuff I currently work on we
use integers for money, for example, and I've never needed to use cost
as an index in to an array!
>
I posted a study for you. You do need a little bit of insight to
intepret data, unless you have the resources to study everything by
brute force.

I explained why the study did not prove the point. Amongst other things,
it explicitly excluded major classes of code, such as server
application s.
This is an important point.
Finding an objection to evidence doesn't make that evidence disappear,

If the objections are valid then it means the evidence is not relevant.
>or turn the opposite case into a "mere assertion" position.

If you have no evidence for which there are not valid objections then your
position is merely your opinion.
No. You are comitting the fallacy.
Prosecutor: Bloggs saw Muggins kill the victim.
Defence: But Bloggs is a drugs dealer who has a grudge against Muggins.

True.
Therefore there is a "no evidence" position against Muggins? No. Whilst it
is plausible that Bloggs is making the allegation up, we have a dead body
and a claim that Muggins did it.
>
>You seldom have exactly the evidence you would like.

That is why people conduct studdies. Some times those studdies can be done
by taking the raw data from a number of other studdies, but you have to
design your study first then go and collect the data from the other
studies.
No. Ideally this would happen, but you can't snap your fingers and summon
data into existence.
>
For instance the
example I gave was Java, not C, it was from a selection of about ten
applications , and the study wasn't designed to show what I asserted, the
conclusion had to be derived by looking at the evidence with some
assumptions.

Assumptions which have to be justified, especially if challenged. You have
not given any justification for your assumptions (which you did not state)
or explanation of why my challenges are wrong.
The challenges are not wrong. To use our prosecutor analogy, it is perfectly
valid for the defence the point out that Bloggs is a drugs dealer. The
fallacy is in supposing that therefore Blogg's evidence disappears.
"Therefore, " says the defence, "isn't it suprising that Muggins fired a shot
and no-one heard it?" Totally invalid, because he has manufactured an
absence of Blogg's evidence.

In your case it was quite right to point out the weaknesses in my approach,
which were real, but they do not make the evidence disappear.
>
>However whilst your objections were legitimate, in fact the idea that
Java code is very different from C code in its use of arrays, that server
applications use arrays in a very different way from most general
applications , that array access instructions don't bear a very tight
relationship to index calculations, and so on, aren't all that plausible.

I gave specific reasons why certain classes of applications do a lot of
integer work that is not to do with indexing. Here is another, a number of
the SQL data types are either integer types (which will be impleneted as
integer types) or scaled integer types (which will be implemented as
integer types with the scaling stored as part of the column definition.
The manipulation of those integer types will be on the basis of SQL
queries, summing costs etc. On financial applications, such as Sun
Financials, they make use of such types a lot, and hardly any use of
arrays. I suspect that there is a LOT of financial SW out there where they
do not want to use floating point for numbers because the law does not
permit them to have rounding errors (or specifies specific rounding which
you won't be able to guarantee with floating point numbers).

Probable most "indexing" done by a database is indexing in to a file, not
memory, so by that argument we need int to be large enough to store the
size of the largest table that might be required, and that is independent
of the processor!
It is possible that you are right and the example suite of program used in
the study was not representative. When you say that evidence has weakness,
ultimately you may be right. Certainly by using a database with a query
interface we have eliminated a lot of array accesses. Then there is a
question of whether you count internal indexing by the database system -
what exactly are we interested in?
>
You would need to do a proper study to establish the matter
beyond all possible doubt.

You would need to do rather more than look at one very biased sample to
have any significant evidence.
A sample of one tells you what the probable answer is.
>
However do you think I could get a research
grant for people to sit tagging up C code to establish how much indexing
is done? It would be expensive and wouldn't tell us very much that we
don't know already.

So far the only person to jump in on either side is Richard Heathfield,
and he seems to take the opposing view. So another biased sampling shows
that most C developers either have no opinion on the subject or disagree
with you.
True. I think what happens is that most people think of the results as _the_
calcualtion, and the indexing as intermediates. So if you up twenty salaries
by 10% you are doing twenty multiplications . In fact you are probably doing
five of six array calculations as well.
>
Most scientific studies have tight cost limits and
aren't as rigorous as we would like. That doesn't mean that they are
useless.

True, but they have vastly more rigour than looking at a sample that says
it was biased and then using the data for something the collection was not
designed for.
Some do, some don't. In ecology for instance it is often very expensive to
collect data and resources are minimal. In medical trials on the other hand
you can do double blind tests to answer a very narrow question. In our case
I can't be bothered to tag up a representative sample of programs to answer
a fairly minor question, so I'm doing it on the cheap.
>
>You'll often come across this fallacy in a much more gross way than you
have made it. I can find an objection to the evidence, therefore it
disappears.

If a sample can be shown to be biased for the use it is being put to then
you cannot use it on its own as evidence for your point. If you collect
data from enough other studdies with different biases and can show they
cancel out, or you can come up with a way to counteract the bias (with
evidence supporting your method) then you can use it.

Note that I do not claim to know whether overall integer types are used
more for indexing and related operations or for other purposes. I only
claim that my experience contradicts it and that you have no significant
evidence to support your personal opinion.
You've softened your position by saying "no significant evidence" rather
than "no evidence". That doesn't mean you are off the hook for the fallacy,
though does mean that there is at least some awareness.
First you said that the study wasn't representative, but didn't give
a very plausible reason why this would be so - that amounts of money are
often held as integers. All that does is shift a few flaoting point
operations to integers. Now you've come back with a second reason, that the
main data structures might not be held in arrays because they are in
databases. That's more plausible, and you mgiht just be right, particuarly
if we exclude internal indexing done by the query system, which is arguably
legitimate. However the Java sample showed such a large number of array
index operations that it isn't at all obvious that even this would shift it.
But maybe, just maybe, you are right for one class of applications.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Apr 14 '07 #85

"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:n7******** ***@news.flash-gordon.me.uk...
Army1987 wrote, On 14/04/07 12:20:
>"Malcolm McLean" <re*******@btin ternet.comha scritto nel messaggio
news:iN******* *************** ********@bt.com ...

<snip>
>>Virtually every integer, pace Flash Gordon, is used as an array index or
in intermediate calculations to derive indices. But since size_t is
unsigned, awkward to read, and most numbers are much less than 2
billion, people won't use it consistently.

If the problem is that size_t is unsigned, use ptrdiff_t. But, first, ask
yourself wheter you *really* need it.

That reminds me, you also have intptr_t and uintptr_t which, if present,
are guaranteed to be large enough to hold and pointer, so by inference are
going to be as large as the address bus (unless pointers are narrower than
the address bus).
You see where this is leading? Anyone still disbelieve in the existence of
gibberish types?

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Apr 14 '07 #86
In article <iN************ *************** ***@bt.com>,
Malcolm McLean <re*******@btin ternet.comwrote :
>I want a type called "int" and signed that is the size of the address bus.
To be fernickety about it it really needs an extra bit, but in practise if
you need over half the address space for a single array then you can code
access to it specially.
That has been the convention until now. The proposal is to change it, to
make int no longer the natural integer size for the machine.
It has not "been the convention until now". It was not, for
example, true in the SGI IRIX 64 bit machines introduced late
in 1994; they used LP64 (int 32 bits, long and pointer 64 bits.)
That was before Windows 95, to give you an idea of how many software
generations have been gone through since then.
--
"It is important to remember that when it comes to law, computers
never make copies, only human beings make copies. Computers are given
commands, not permission. Only people can be given permission."
-- Brad Templeton
Apr 14 '07 #87
Malcolm McLean wrote, On 14/04/07 15:53:
>
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:n7******** ***@news.flash-gordon.me.uk...
>Army1987 wrote, On 14/04/07 12:20:
>>"Malcolm McLean" <re*******@btin ternet.comha scritto nel messaggio
news:iN****** *************** *********@bt.co m...

<snip>
>>>Virtually every integer, pace Flash Gordon, is used as an array
index or in intermediate calculations to derive indices. But since
size_t is unsigned, awkward to read, and most numbers are much less
than 2 billion, people won't use it consistently.

If the problem is that size_t is unsigned, use ptrdiff_t. But, first,
ask yourself wheter you *really* need it.

That reminds me, you also have intptr_t and uintptr_t which, if
present, are guaranteed to be large enough to hold and pointer, so by
inference are going to be as large as the address bus (unless pointers
are narrower than the address bus).
You see where this is leading? Anyone still disbelieve in the existence
of gibberish types?
So any type other than int that would serve your purpose is a gibberish
type then? That certainly seems to be your point, and if so it looks
more like you are spouting gibberish.

int it there for integer arithmetic, nothing more and nothing less. If
you have more specific requirements then it is obvious that you need a
more specific type.
--
Flash Gordon
Apr 14 '07 #88
Malcolm McLean wrote, On 14/04/07 15:48:
>
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:7l******** ****@news.flash-gordon.me.uk...
>Malcolm McLean wrote, On 14/04/07 09:09:
>>>
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:tn****** *****@news.flas h-gordon.me.uk...
Malcolm McLean wrote, On 12/04/07 22:03:
>
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:en**** ********@news.f lash-gordon.me.uk...
>Malcolm McLean wrote, On 12/04/07 08:07:

<snip>

Since most integers are used in array indexes, i.e.
>>count things in the computer's memory, that tells you what the
>>natural integer size is on any particualr machine.
>>
>You've claimed that before and failed to support it. In over 20
>years of professional programming most of my use of integers has
>not had anything to do with array indexes. On the stuff I
>currentl y work on we use integers for money, for example, and I've
>never needed to use cost as an index in to an array!
>>
I posted a study for you. You do need a little bit of insight to
intepret data, unless you have the resources to study everything by
brute force.

I explained why the study did not prove the point. Amongst other
things, it explicitly excluded major classes of code, such as server
applications .

This is an important point.
Finding an objection to evidence doesn't make that evidence disappear,

If the objections are valid then it means the evidence is not relevant.
>>or turn the opposite case into a "mere assertion" position.

If you have no evidence for which there are not valid objections then
your position is merely your opinion.
No. You are comitting the fallacy.
Prosecutor: Bloggs saw Muggins kill the victim.
Defence: But Bloggs is a drugs dealer who has a grudge against Muggins.

True.
Therefore there is a "no evidence" position against Muggins? No. Whilst
it is plausible that Bloggs is making the allegation up, we have a dead
body and a claim that Muggins did it.
Your analogy is completely bogus because in this case Blogs said
something mode like "Muggins has more guns than his wife, Fred has more
guns than his wife, therefore most men have more weapons than their
wives". Your study claimed nothing about what you are trying to prove,
you are trying to use the data collected from a study for purposes other
than that the data collection strategy was designed for. One of the
major reasons for studies giving inaccurate results is poor data
collection, and that is something you are suffering from.
>>You seldom have exactly the evidence you would like.

That is why people conduct studdies. Some times those studdies can be
done by taking the raw data from a number of other studdies, but you
have to design your study first then go and collect the data from the
other studies.
No. Ideally this would happen, but you can't snap your fingers and
summon data into existence.
So? Your inability to generate good evidence does not mean people should
collect poor evidence.
For instance the
example I gave was Java, not C, it was from a selection of about ten
application s, and the study wasn't designed to show what I asserted,
the conclusion had to be derived by looking at the evidence with some
assumptions .

Assumptions which have to be justified, especially if challenged. You
have not given any justification for your assumptions (which you did
not state) or explanation of why my challenges are wrong.
The challenges are not wrong.
Since you accept that, either provide evidence that does not have those
weaknesses or accept that you are just giving your opinion.
To use our prosecutor analogy, it is
perfectly valid for the defence the point out that Bloggs is a drugs
dealer. The fallacy is in supposing that therefore Blogg's evidence
disappears. "Therefore, " says the defence, "isn't it suprising that
Muggins fired a shot and no-one heard it?" Totally invalid, because he
has manufactured an absence of Blogg's evidence.
Incorrect analogy as stated above.
In your case it was quite right to point out the weaknesses in my
approach, which were real, but they do not make the evidence disappear.
Since I have equally "good" evidence that contradicts what you are
claiming, and I have presented it, there balance is that there is no
objective reason for believing what you claim as fact.
>>However whilst your objections were legitimate, in fact the idea that
Java code is very different from C code in its use of arrays, that
server applications use arrays in a very different way from most
general applications, that array access instructions don't bear a
very tight relationship to index calculations, and so on, aren't all
that plausible.

I gave specific reasons why certain classes of applications do a lot
of integer work that is not to do with indexing. Here is another, a
number of the SQL data types are either integer types (which will be
impleneted as integer types) or scaled integer types (which will be
implemented as integer types with the scaling stored as part of the
column definition. The manipulation of those integer types will be on
the basis of SQL queries, summing costs etc. On financial
applications , such as Sun Financials, they make use of such types a
lot, and hardly any use of arrays. I suspect that there is a LOT of
financial SW out there where they do not want to use floating point
for numbers because the law does not permit them to have rounding
errors (or specifies specific rounding which you won't be able to
guarantee with floating point numbers).

Probable most "indexing" done by a database is indexing in to a file,
not memory, so by that argument we need int to be large enough to
store the size of the largest table that might be required, and that
is independent of the processor!
It is possible that you are right and the example suite of program used
in the study was not representative. When you say that evidence has
weakness, ultimately you may be right.
So either present decent evidence or accept you are stating oppinion not
fact.
Certainly by using a database
with a query interface we have eliminated a lot of array accesses.
Most of my other work has not required array access in the first place.
Then
there is a question of whether you count internal indexing by the
database system - what exactly are we interested in?
You claiming that integer arithmetic is mainly used for array access and
therefore int should be the same width as the address bus. As the
database would be looking up in a file, not in memory, the width of the
address bus is irrelevant in such an instance as I explained either in
this or another recent post.
You would need to do a proper study to establish the matter
beyond all possible doubt.

You would need to do rather more than look at one very biased sample
to have any significant evidence.
A sample of one tells you what the probable answer is.
You would not pass any statistics course if you honestly believe that.
However do you think I could get a research
grant for people to sit tagging up C code to establish how much
indexing is done? It would be expensive and wouldn't tell us very
much that we don't know already.

So far the only person to jump in on either side is Richard
Heathfield, and he seems to take the opposing view. So another biased
sampling shows that most C developers either have no opinion on the
subject or disagree with you.
True. I think what happens is that most people think of the results as
_the_ calcualtion, and the indexing as intermediates.
What evidence do you have that this is the reason for Richard's opinion?
So if you up
twenty salaries by 10% you are doing twenty multiplications . In fact you
are probably doing five of six array calculations as well.
Actually, it is more likely to be adding up the salaries of several
thousand people and involve exactly ZERO array or other memory indexing
operations because the data is help in a database not in memory. Even if
it was a simple array, the code
for (i=0; i<no_employees ; i++)
tax += (salary[i] * scaled_tax) / 100;

Involves for indexing one increment and one indexing, so that is two
operations to do with indexing. However, it has an addition, a
multiplication and a division which are to do with money, not indexing.

In reality, you would be doing a database lookup which might involve an
array lookup or three, then doing far more complex integer operations on
the data fetched. So the balance is even further against your position.
Most scientific studies have tight cost limits and
aren't as rigorous as we would like. That doesn't mean that they are
useless.

True, but they have vastly more rigour than looking at a sample that
says it was biased and then using the data for something the
collection was not designed for.
Some do, some don't. In ecology for instance it is often very expensive
to collect data and resources are minimal.
So they either collect data targetted at what they are trying to prove
or use the raw data from several studies, not just one.
In medical trials on the
other hand you can do double blind tests to answer a very narrow
question. In our case I can't be bothered to tag up a representative
sample of programs to answer a fairly minor question, so I'm doing it on
the cheap.
By doing it on the cheap you are failing to prove the point. In any
case, I originally asked you if you had any evidence for what you
were claiming, and the answer to that question was obviously no or you
would have had no need to go looking for evidence! So you started by
claiming your personal opinion as fact and have since tried to use a
study designed to demonstrate something else which you have admitted has
at least serious weaknesses for your purposes. So you are STILL not in a
position to claim it as fact.
>>You'll often come across this fallacy in a much more gross way than
you have made it. I can find an objection to the evidence, therefore
it disappears.

If a sample can be shown to be biased for the use it is being put to
then you cannot use it on its own as evidence for your point. If you
collect data from enough other studdies with different biases and can
show they cancel out, or you can come up with a way to counteract the
bias (with evidence supporting your method) then you can use it.

Note that I do not claim to know whether overall integer types are
used more for indexing and related operations or for other purposes. I
only claim that my experience contradicts it and that you have no
significant evidence to support your personal opinion.
You've softened your position by saying "no significant evidence" rather
than "no evidence". That doesn't mean you are off the hook for the
fallacy, though does mean that there is at least some awareness.
One person saying "X is true" is evidence, but it does not prove it or
even on something like this give any real reason to believe it.
First you said that the study wasn't representative, but didn't
give a very plausible reason why this would be so
Yes I did. I pointed out one major class of SW that was EXPLICITLY
excluded from the study, and other classes of SW that it did not seem to
cover. A bit like saying "most people are taller than 165cm based on
this study that explicitly excluded asians from the data it was collecting."
- that amounts of
money are often held as integers. All that does is shift a few flaoting
point operations to integers.
That was only ONE instance, I gave others as well. Also, on financial
software MOST of the operations are on money, so it shift a VAST NUMBER
of operations from floating point to integer.
Now you've come back with a second reason,
No, I had already given more than two reasons. You obviously did not
read all of it which would explain you not addressing all of the points.
that the main data structures might not be held in arrays because they
are in databases. That's more plausible, and you mgiht just be right,
particuarly if we exclude internal indexing done by the query system,
which is arguably legitimate.
Since indexes in to files are not related to the size of the address bus
I would say it was a very strong argument. In any case, the lookups are
done using hashes and binary trees, and a binary tree does not do
indexing calculations it just reads and follows the pointer!
However the Java sample showed such a
large number of array index operations that it isn't at all obvious that
even this would shift it. But maybe, just maybe, you are right for one
class of applications.
Mayby I am right for the other classes of applications I mentioned as
well. Unless you think that image processing and avionics systems are
the same class of applications as financial applications. I can add
stabilised motor control of various forms to the list of things I've
done with integer arithmetic without use of arrays.

Also you pointed out that indexing operations are used for accessing
local variables, and I pointed out that there can be a lot of that
without the use of arrays, so without a more detailed analysis of what
the instructions were being used for (which the data you quoted does not
allow) you still don't know that even on that study it was mainly array
operations.

Remember that these are things I've spent years working on so I know how
they are done. Also there are all the other classes of applications
neither of us know anything about. In addition to the point you failed
to address that Java tends to be used for different types of application
designed in a different way to that which C is used for.
--
Flash Gordon
Apr 14 '07 #89
"Malcolm McLean" <re*******@btin ternet.comwrite s:
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:n7******** ***@news.flash-gordon.me.uk...
>Army1987 wrote, On 14/04/07 12:20:
>>"Malcolm McLean" <re*******@btin ternet.comha scritto nel
messaggio news:iN******** *************** *******@bt.com. ..

<snip>
>>>Virtually every integer, pace Flash Gordon, is used as an array
index or in intermediate calculations to derive indices. But since
size_t is unsigned, awkward to read, and most numbers are much
less than 2 billion, people won't use it consistently.

If the problem is that size_t is unsigned, use ptrdiff_t. But,
first, ask yourself wheter you *really* need it.

That reminds me, you also have intptr_t and uintptr_t which, if
present, are guaranteed to be large enough to hold and pointer, so
by inference are going to be as large as the address bus (unless
pointers are narrower than the address bus).
You see where this is leading? Anyone still disbelieve in the
existence of gibberish types?
They are not gibberish. There are simply different names for types
intended for different purposes. Most of us don't have a problem with
that; I'm not sure why you do.

--
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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Apr 14 '07 #90

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

Similar topics

5
5237
by: dba_db2 at nospam gmx.net | last post by:
We have got a brand new mutltiprocessor machine IBM pseries server with 2 processors. Now we want to buy a IBM DB2 license for this box. Does anyone know whether it is possible to buy a single processor db2 license for this machine and to configure the db2 software with db2licm just to use one processor.
1
3478
by: Mateusz Rajca | last post by:
Hello, I would like to know how to find the specs of the current running system such as the memory amount and processor speed in C#? Mateusz
3
1442
by: Michel Meex | last post by:
Hello, I have an application, that has been running on a single processor server for more then a year without any problems. Now I'm migrating to a dual processor server, and I'm experiencing problems with threading. The application is actually a kind of job schedular. For all jobs, I can set a recurring interval (daily,weekly, monthly etc) at which the specific job should be started. We program each job, according to an interface....
1
1402
by: Michel Meex | last post by:
Hello, I have an application, that has been running on a single processor server for more then a year without any problems. Now I'm migrating to a dual processor server, and I'm experiencing problems with threading. The application is actually a kind of job schedular. For all jobs, I can set a recurring interval (daily,weekly, monthly etc) at which the specific job should be started. We program each job, according to an interface....
11
2321
by: sunil | last post by:
Dear All, I have created a .Net service in 2.0 and running it on a machine that has a Quad Processor. It is failing with the following error. "Error 1053: The service did not respond to the start or control request in a timely fashion" This is what I saw in event Viewer. Timeout (30000 milliseconds) waiting for the MyService Server service to connect.
5
6591
by: nano2k | last post by:
Hi I need to protect my application in a way. Just a "soft" protection, not a very strong one. So, using WMI I get the processor ID and compare it against a key. Protection works well, until someone (me) decides to clone the system. After cloning, all cloned systems work with the same key. That is, WMI returns the same processor id on all workstations. It seems that Windows "caches" the processor ID in the registry or somewhere else - I...
10
7010
by: WannaKatana | last post by:
I am just wondering why, with nothing else running and executing an update query against a very large table, does Access seem to be causing less than 10% processor usage. Then it says "There is not enough disk space or memory to undo the changes". I have 2 gb RAM, Core 2 duo e6300 processor and plenty of disk space. Why doesn't Access peg the CPU? Joel
11
6494
by: kyosohma | last post by:
Hi, We use a script here at work that runs whenever someone logs into their machine that logs various bits of information to a database. One of those bits is the CPU's model and speed. While this works in 95% of the time, we have some fringe cases where the only thing returned is the processor name. We use this data to help us decide which PCs need to be updated, so it would be nice to have the processor speed in all cases.
2
6181
by: raghavv | last post by:
Hi, I have developed a software.For licensing it i need to access a unique number of a computer like mother board id or processor id. Is there a way to get this info.In C# we can use system.management to get this info.Is there anything similar to this in java. If not How can i do this. Thank you...
0
9404
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
10168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10008
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...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9837
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6651
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
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
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.