unexpected behaviour of for loop?

hi thank you for your comments.
Last edited on
1
2
3
4
5
6
7
8
9
ht = -J*(a[0]*(a[1]+a[6]) +a[1]*(a[2]+a[7]) +a[2]*(a[3]+a[8]) +a[3]*(a[4]+a[9]) +a[4]*(a[5]+a[10]) +a[5]*
(a[0]+a[11])+a[6]*(a[7]+a[12]) +a[7]*(a[8]+a[13]) +a[8]*(a[9]+a[14]) +a[9]*(a[10]+a[15])+a[10]*(a[11]+a[16])+a[11]*
(a[6]+a[17])+a[12]*(a[13]+a[18])+a[13]*(a[14]+a[19])+a[14]*(a[15]+a[20])+a[15]*(a[16]+a[21])+a[16]*
(a[17]+a[22])+a[17]*(a[12]+a[23])+a[18]*(a[19]+a[24])+a[19]*(a[20]+a[25])+a[20]*(a[21]+a[26])+a[21]*
(a[22]+a[27])+a[22]*(a[23]+a[28])+a[23]*(a[18]+a[29])+a[24]*(a[25]+a[30])+a[25]*(a[26]+a[31])+a[26]*
(a[27]+a[32])+a[27]*(a[28]+a[33])+a[28]*(a[29]+a[34])+a[29]*(a[24]+a[35])+a[30]*(a[31]+a[0])+a[31]*
(a[32]+a[1])+a[32]*(a[33]+a[2])+a[33]*(a[34]+a[3])+a[34]*(a[35]+a[4])+a[35]*(a[30]+a[5])) - 
H*(a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]+a[10]+a[11]+a[12]+a[13]+a[14]+a[15]+a[16]+a[17]+
a[18]+a[19]+a[20]+a[21]+a[22]+a[23]+a[24]+a[25]+a[26]+a[27]+a[28]+a[29]+a[30]+a[31]+a[32]+a[33]+a[34]+a[35]);


Ouch.

How can you expect any mortal to understand that?

Are you sure every hard-coded index you have there is right?

What's it even supposed to do???
Last edited on
:O
Aside from that ridiculousness:

1
2
3
# define N 36
# define SIZE pow(2,N)   // 2^36
n = (long int)SIZE;   // overflow 


Use long long instead of ints, or reduce N to 30 (or 31 if you go unsigned)
Topic archived. No new replies allowed.