473,320 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Meaning of this array

Hi all,

i can't figure out what this means.
i'm trying to rewrite it in delphi.
Can anyone help?

declaration:
word pp[2][8];
word j;

code:
word * a = pp[ j ];
word * a_1 = pp[ j ^=1 ];

Thanks, J.
Nov 24 '05 #1
5 2008
Jozza wrote:
Hi all,

i can't figure out what this means.
i'm trying to rewrite it in delphi.
Can anyone help?
Which part of it don't you understand.
j ^= 1 is the same as
j = j ^ 1;

^ is bitwise xor. This flips the low order
bit (i.e., if j is 1, yields 0,
2 3
3 2
..

Nov 24 '05 #2
Jozza wrote:
Hi all,

i can't figure out what this means.
i'm trying to rewrite it in delphi.
Can anyone help?

declaration:
word pp[2][8];
word j;

code:
word * a = pp[ j ];
word * a_1 = pp[ j ^=1 ];

Thanks, J.


In effect,

'pp' is two arrays of 'word', each array is 8 long.

Depending on the value of 'j' (which must be 0 or 1) 'a' is used to
access one of the two pp arrays, and 'a_1' is the other one. During this
process the value of j is flipped, i.e. if it was 1 before it is 0 after
and vice versa.

john
Nov 24 '05 #3
Hi,

Yes, I presented the question a little oddly.
The problem was, why does pp only specify one dimension in the code when the
declaration was two dimensional.
So "a" is accessing the complete first/second dimension of the array and
a_1 is accessing the array dependent on j's value.
Hmm, i might begin to love c++ :)

Thanks John
"John Harrison" <jo*************@hotmail.com> wrote in message
news:mA*****************@newsfe3-gui.ntli.net...
Jozza wrote:
Hi all,

i can't figure out what this means.
i'm trying to rewrite it in delphi.
Can anyone help?

declaration:
word pp[2][8];
word j;

code:
word * a = pp[ j ];
word * a_1 = pp[ j ^=1 ];

Thanks, J.


In effect,

'pp' is two arrays of 'word', each array is 8 long.

Depending on the value of 'j' (which must be 0 or 1) 'a' is used to access
one of the two pp arrays, and 'a_1' is the other one. During this process
the value of j is flipped, i.e. if it was 1 before it is 0 after and vice
versa.

john

Nov 25 '05 #4
Jozza wrote:
"John Harrison" <jo*************@hotmail.com> wrote in message
news:mA*****************@newsfe3-gui.ntli.net...
Jozza wrote:
Hi all,

i can't figure out what this means.
i'm trying to rewrite it in delphi.
Can anyone help?

declaration:
word pp[2][8];
word j;

code:
word * a = pp[ j ];
word * a_1 = pp[ j ^=1 ];

Thanks, J.


In effect,

'pp' is two arrays of 'word', each array is 8 long.

Depending on the value of 'j' (which must be 0 or 1) 'a' is used to access
one of the two pp arrays, and 'a_1' is the other one. During this process
the value of j is flipped, i.e. if it was 1 before it is 0 after and vice
versa.

john


Hi,

Yes, I presented the question a little oddly.
The problem was, why does pp only specify one dimension in the code when the
declaration was two dimensional.
So "a" is accessing the complete first/second dimension of the array and
a_1 is accessing the array dependent on j's value.
Hmm, i might begin to love c++ :)


First, don't top-post. Put your post inline or below the one you are
responding to. I fixed your response above.

Second, a and a_1 in your code are pointers to a single row of an
array. *Both* depend on the value of j, which must be either 0 or 1
(one hopes that there was error checking before the two assignments you
show, lest strange errors occur). The code is cleverly but poorly
written, IMHO, because it is hard to understand. Clearer would be to
have one statement per line and to use const everywhere possible (the
context would determine where that is):

assert( 0 == j || 1 == j );
const word *const a = pp[ j ];
j ^= 1; // Toggle bit
const word *const a_1 = pp[ j ];

Cheers! --M

Nov 25 '05 #5

"mlimber" <ml*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Jozza wrote:
"John Harrison" <jo*************@hotmail.com> wrote in message
news:mA*****************@newsfe3-gui.ntli.net...
> Jozza wrote:
>> Hi all,
>>
>> i can't figure out what this means.
>> i'm trying to rewrite it in delphi.
>> Can anyone help?
>>
>> declaration:
>> word pp[2][8];
>> word j;
>>
>> code:
>> word * a = pp[ j ];
>> word * a_1 = pp[ j ^=1 ];
>>
>> Thanks, J.
>>
>>
>
> In effect,
>
> 'pp' is two arrays of 'word', each array is 8 long.
>
> Depending on the value of 'j' (which must be 0 or 1) 'a' is used to
> access
> one of the two pp arrays, and 'a_1' is the other one. During this
> process
> the value of j is flipped, i.e. if it was 1 before it is 0 after and
> vice
> versa.
>
> john
Hi,

Yes, I presented the question a little oddly.
The problem was, why does pp only specify one dimension in the code when
the
declaration was two dimensional.
So "a" is accessing the complete first/second dimension of the array and
a_1 is accessing the array dependent on j's value.
Hmm, i might begin to love c++ :)


First, don't top-post. Put your post inline or below the one you are
responding to. I fixed your response above.


Ok. I'll get used to it in the future :)

Second, a and a_1 in your code are pointers to a single row of an
array. *Both* depend on the value of j, which must be either 0 or 1
(one hopes that there was error checking before the two assignments you
show, lest strange errors occur). The code is cleverly but poorly
written, IMHO, because it is hard to understand. Clearer would be to
have one statement per line and to use const everywhere possible (the
context would determine where that is):

assert( 0 == j || 1 == j );
const word *const a = pp[ j ];
j ^= 1; // Toggle bit
const word *const a_1 = pp[ j ];

Cheers! --M

I didn't know until now that multi dimensional arrays can be accessed this
way (that syntax would be allowed, at least not in delphi)
but it works in delphi also.
Thanks,
J.
Nov 25 '05 #6

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

Similar topics

24
by: krishna | last post by:
Hi all, char a; will declare character array of size 10 starting with the index 0. what is the meaning of the following declaration? what is the purpose of such declarations? char a; ...
5
by: Omats.Z | last post by:
what is meaning os "char **option meet"? I get a function like this: __________________________________ int getchoice(char *greet, char *choices) { int chosen = 0; int selected; char **option;...
11
by: sam | last post by:
What is the meaning of this operator:- => Please tell about this.
5
by: sam | last post by:
HI, Whats the meaning of this code:- char buff; memset(buff, 'A' , 100); sometimes we can place hex value in place of 'A' like 0x90c but how this code function actually. thanks in advance
4
by: _mario.lat | last post by:
for struct: struct in6_addr { uint8_t s6_addr; }; is provided a costant: #define IN6ADDR_LOOPBACK_INIT {{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}}} what does means {{{, and }}}?
14
by: Summercool | last post by:
The meaning of a = b in object oriented languages. ==================================================== I just want to confirm that in OOP, if a is an object, then b = a is only copying the...
4
by: Baby Lion | last post by:
it just makes me feel confusing ... what does ^ mean , and how to use it . thanks,
20
by: somenath | last post by:
Hi All, I have one question regarding the code. #include<stdio.h> char *f1(void); char *f1(void) { char *abc ="Hello";
2
by: Rick Giuly | last post by:
Hello All, Case 1 This generates an error, which makes sense because the argument should be a list of numbers: numpy.array(10,10) Case 2 This does not generate an error and the result is an...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.