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. 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
..
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++ :)
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
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
"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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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;
...
|
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;...
|
by: sam |
last post by:
What is the meaning of this operator:-
=>
Please tell about this.
|
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
|
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 }}}?
|
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...
|
by: Baby Lion |
last post by:
it just makes me feel confusing ...
what does ^ mean , and how to use it .
thanks,
|
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";
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
| |