I need someone who uses C/C++ to give me a quick confirmation here:

C defines arrays by a 1 based system, while accessing data from the array is 0 based, right?

ie.

doubles myarray[128]


Then the range of data is accessed from:

myarray[0] -> myarray[127]


Is this correct?? (its for an asm transcription im doing here (fft) )

Thanx.
:NaN:
Posted on 2003-05-13 19:06:20 by NaN
I don't know if you should confuse it by saying there's a 0 based or 1 based whatever.

When you define an array, you give the size, wheras when you address an element, you give the offset/index.

int foo[20]; declares an array of 20 ints, indexed from 0 to 19.
Posted on 2003-05-13 19:43:11 by iblis
yes but in languages like VB array(0) gives you an array with 1 element :tongue:

it really all depends on the implementation. I'm used to thinking of 0 as the first index but sometimes wonder wether 1 wouldn't be better. I have too many code where I do
Posted on 2003-05-13 19:57:20 by Hiroshimator
soooo very frustrated...

Im very close to haveing it hacked. It turns out there is some sorta indexing issue. By subtracting 8 (size of qword) from the base address, i get proper results, however, the phase is inversed. All amplitudes are correct, and frequency bins are correct.

Else, the phase is approximately right, and the magnitude is also approximately right. Still hacking at it...

:NaN:
Posted on 2003-05-13 20:46:34 by NaN
if it is zero based just go ahead and waste the zeroeth elment if it helps your thinking so what are you out by doing this 8 bytes at most

or redo it in asembly so you know for certan what the computer is doing
with your data (it may be easyer than doing it in C++ anyway)

you could write a small test program that would show you what is going on
Posted on 2003-05-14 11:41:47 by rob.rice
If you follow the link above you'll see i am doing an ASM version..
Posted on 2003-05-14 16:54:17 by NaN