Re: return the start of a substring in a string in c
- From: "Malcolm McLean" <regniztar@xxxxxxxxxxxxxx>
- Date: Sat, 14 Jul 2007 19:29:15 +0100
"Ben Bacarisse" <ben.usenet@xxxxxxxxx> wrote in message
Why do say integers usually count things? Don't you ever calculateAs Flash says, we've been through all this before. I even pulled up some Java stats that showed pretty clearly that there were about as many indexed array accesses as integer operations in a sample of Java programs. I couldn't find a similar study for C, though I didn't try too hard, but there is no reason to suppose that C programs are radically different from Java ones.
things with integers? I used to work on projects (cryptography stuff)
where calculating was more common than counting and ints were
always too short. Counting is usually done with integers, but you
can't turn that round the other way.
Computers spend most of their cycles moving data from one place to another, and most integers are used to count things in the computer's memory. That's not every cycle, of course, nor is every single integer a count of something - cryptography is an obvious exception, as are intermediate results in frequency transforms, or pixel colours. The last leads us to another issue, in a typical image function
void setpixel(long *img, int width, int height, int x, int y, long val)
{
assert(x >= 0 && x < width);
assert*y >= 0 && y < height);
img[y*width + x] = height;
}
How many integers do we have? You could say width * height, plus a few, or you could say six, of which two are pixel values and four intermediates in array calculations. I'm counting it as six, which isn't the only answer justifiable, but makes sense in the context of how best to define the types in a high-level language.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
.
- Follow-Ups:
- Re: return the start of a substring in a string in c
- From: Ben Bacarisse
- Re: return the start of a substring in a string in c
- From: Army1987
- Re: return the start of a substring in a string in c
- From: Flash Gordon
- Re: return the start of a substring in a string in c
- References:
- return the start of a substring in a string in c
- From: yinglcs@xxxxxxxxx
- Re: return the start of a substring in a string in c
- From: Richard Heathfield
- Re: return the start of a substring in a string in c
- From: Malcolm McLean
- Re: return the start of a substring in a string in c
- From: Harald van Dijk
- Re: return the start of a substring in a string in c
- From: Malcolm McLean
- Re: return the start of a substring in a string in c
- From: Flash Gordon
- Re: return the start of a substring in a string in c
- From: Malcolm McLean
- Re: return the start of a substring in a string in c
- From: Ben Bacarisse
- return the start of a substring in a string in c
- Prev by Date: Re: MinGW: How do I temporarily disable stderr in a C(++) program
- Next by Date: Re: MinGW: How do I temporarily disable stderr in a C(++) program
- Previous by thread: Re: return the start of a substring in a string in c
- Next by thread: Re: return the start of a substring in a string in c
- Index(es):
Relevant Pages
|