IAJWDDIY
asked on
C to VB.Net conversion
Hello,
Can anyone explain the following code in C to help me try to translate to VB.Net?
The define part I understand - someone kindly explained this to me yesterday.
Thank you.
#define S1(a) (((a&2)>>1) | ((a&1)<<2))
#define S2(a) (((a&2)>>0) | ((a&1)<<3))
#define S3(a) (((a&2)>>1) | ((a&1)<<2))
#define S4(a) (((a&2)>>0) | ((a&1)<<3))
#define S5(a) (((a&2)>>1) | ((a&1)<<2))
#define S6(a) (((a&2)>>0) | ((a&1)<<3))
#define S7(a) a
static const int x[] = {
S1(2),S1(0),S1(1),S1(1),S1 (2),S1(3), S1(3),S1(0 ),
S1(3),S1(2),S1(2),S1(0),S1 (1),S1(1), S1(0),S1(3 ),
S1(0),S1(3),S1(3),S1(0),S1 (2),S1(2), S1(1),S1(1 ),
S1(2),S1(2),S1(0),S1(3),S1 (1),S1(1), S1(3),S1(0 )
};
static const int x[] = {
S2(3),S2(1),S2(0),S2(2),S2 (2),S2(3), S2(3),S2(0 ),
S2(1),S2(3),S2(2),S2(1),S2 (0),S2(0), S2(1),S2(2 ),
S2(3),S2(1),S2(0),S2(3),S2 (3),S2(2), S2(0),S2(2 ),
S2(0),S2(0),S2(1),S2(2),S2 (2),S2(1), S2(3),S2(1 )
};
static const int x[] = {
S3(2),S3(0),S3(1),S3(2),S3 (2),S3(3), S3(3),S3(1 ),
S3(1),S3(1),S3(0),S3(3),S3 (3),S3(0), S3(2),S3(0 ),
S3(1),S3(3),S3(0),S3(1),S3 (3),S3(0), S3(2),S3(2 ),
S3(2),S3(0),S3(1),S3(2),S3 (0),S3(3), S3(3),S3(1 )
};
static const int x[] = {
S4(3),S4(1),S4(2),S4(3),S4 (0),S4(2), S4(1),S4(2 ),
S4(1),S4(2),S4(0),S4(1),S4 (3),S4(0), S4(0),S4(3 ),
S4(1),S4(0),S4(3),S4(1),S4 (2),S4(3), S4(0),S4(3 ),
S4(0),S4(3),S4(2),S4(0),S4 (1),S4(2), S4(2),S4(1 )
};
static const int x[] = {
S5(2),S5(0),S5(0),S5(1),S5 (3),S5(2), S5(3),S5(2 ),
S5(0),S5(1),S5(3),S5(3),S5 (1),S5(0), S5(2),S5(1 ),
S5(2),S5(3),S5(2),S5(0),S5 (0),S5(3), S5(1),S5(1 ),
S5(1),S5(0),S5(3),S5(2),S5 (3),S5(1), S5(0),S5(2 )
};
static const int x[] = {
S6(0),S6(1),S6(2),S6(3),S6 (1),S6(2), S6(2),S6(0 ),
S6(0),S6(1),S6(3),S6(0),S6 (2),S6(3), S6(1),S6(3 ),
S6(2),S6(3),S6(0),S6(2),S6 (3),S6(0), S6(1),S6(1 ),
S6(2),S6(1),S6(1),S6(2),S6 (0),S6(3), S6(3),S6(0 )
};
static const int x[] = {
S7(0),S7(3),S7(2),S7(2),S7 (3),S7(0), S7(0),S7(1 ),
S7(3),S7(0),S7(1),S7(3),S7 (1),S7(2), S7(2),S7(1 ),
S7(1),S7(0),S7(3),S7(3),S7 (0),S7(1), S7(1),S7(2 ),
S7(2),S7(3),S7(1),S7(0),S7 (2),S7(3), S7(0),S7(2 )
};
Can anyone explain the following code in C to help me try to translate to VB.Net?
The define part I understand - someone kindly explained this to me yesterday.
Thank you.
#define S1(a) (((a&2)>>1) | ((a&1)<<2))
#define S2(a) (((a&2)>>0) | ((a&1)<<3))
#define S3(a) (((a&2)>>1) | ((a&1)<<2))
#define S4(a) (((a&2)>>0) | ((a&1)<<3))
#define S5(a) (((a&2)>>1) | ((a&1)<<2))
#define S6(a) (((a&2)>>0) | ((a&1)<<3))
#define S7(a) a
static const int x[] = {
S1(2),S1(0),S1(1),S1(1),S1
S1(3),S1(2),S1(2),S1(0),S1
S1(0),S1(3),S1(3),S1(0),S1
S1(2),S1(2),S1(0),S1(3),S1
};
static const int x[] = {
S2(3),S2(1),S2(0),S2(2),S2
S2(1),S2(3),S2(2),S2(1),S2
S2(3),S2(1),S2(0),S2(3),S2
S2(0),S2(0),S2(1),S2(2),S2
};
static const int x[] = {
S3(2),S3(0),S3(1),S3(2),S3
S3(1),S3(1),S3(0),S3(3),S3
S3(1),S3(3),S3(0),S3(1),S3
S3(2),S3(0),S3(1),S3(2),S3
};
static const int x[] = {
S4(3),S4(1),S4(2),S4(3),S4
S4(1),S4(2),S4(0),S4(1),S4
S4(1),S4(0),S4(3),S4(1),S4
S4(0),S4(3),S4(2),S4(0),S4
};
static const int x[] = {
S5(2),S5(0),S5(0),S5(1),S5
S5(0),S5(1),S5(3),S5(3),S5
S5(2),S5(3),S5(2),S5(0),S5
S5(1),S5(0),S5(3),S5(2),S5
};
static const int x[] = {
S6(0),S6(1),S6(2),S6(3),S6
S6(0),S6(1),S6(3),S6(0),S6
S6(2),S6(3),S6(0),S6(2),S6
S6(2),S6(1),S6(1),S6(2),S6
};
static const int x[] = {
S7(0),S7(3),S7(2),S7(2),S7
S7(3),S7(0),S7(1),S7(3),S7
S7(1),S7(0),S7(3),S7(3),S7
S7(2),S7(3),S7(1),S7(0),S7
};
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Kent,
The static const int x[] bit, is that an array?
Thank you.
The static const int x[] bit, is that an array?
Thank you.
yep
that is an array on int values
the number of elemnts in the array is determined by the number of values in the initiation (32 in your case)
remember that c array are zero based
that is an array on int values
the number of elemnts in the array is determined by the number of values in the initiation (32 in your case)
remember that c array are zero based
ASKER
Kent,
Thank you.
Thank you.
Err... The last example should be:
static const int x[] = {
2>>1, 0, 1<<2, 1<<2, 2>>1, 3>>1, 3>>1, 0,
Which is:
static const int x[] = {
1, 0, 4, 4, 1, 1, 1, 0,
Kent