Maximum loop runs?

Understanding the language, error messages, etc.

Maximum loop runs?

Postby wwtom » Sun Jul 19, 2015 4:10 pm

I want to calculate with 3d points.
So I need to try pretty, pretty many points!
And many points = many loops ^^
This is my actual try to test a 64x64x64 room with 0,5 accuracy.
This means 2359296 loop runs per "aS".
I could understand if it would take really long, but it just does nothing. If I fill something like i ++ in the middle, i is 0 at the end :(
Code: Select all
for(int ix = SpC[0] - 32; ix < SpC[0] + 32; ix ++){
    for(int iy = SpC[1] - 32; iy < SpC[1] + 32; iy ++){
      for(int iz = SpC[2] - 32; iz < SpC[2] + 32; iz ++){
        for(int igx = ix; igx < ix + 1; ix = ix + 0,5){
          for(int igz = iz; igz < iz + 1; iz = iz + 0,5){
            for(i = 0; i < aS; i++){


Is there any way to make this work? No problem if its really slow. It already takes about 0,5 min to check the 64x64x64 room with 1 accurancy.
wwtom
 
Posts: 16
Joined: Tue Jun 02, 2015 6:28 pm

Re: Maximum loop runs?

Postby jonnection » Sun Jul 19, 2015 4:29 pm

for(int igx = ix; igx < ix + 1; ix = ix + 0,5)

You can't add 0,5 to an integer (int). The result will be zero all the time.

Proof:

http://goo.gl/TASJm3

Code: Select all
#include <stdio.h>

int main()
{
    int x=0;
    x = x + 0,5;
    printf("x: %f \n",(float)x);
    return 0;
}


Output:

"x: 0.0000"
User avatar
jonnection
 
Posts: 317
Joined: Sun May 04, 2014 8:21 pm

Re: Maximum loop runs?

Postby wwtom » Sun Jul 19, 2015 4:47 pm

Oh man D:
Thank you :o
wwtom
 
Posts: 16
Joined: Tue Jun 02, 2015 6:28 pm


Return to Programming Questions

Who is online

Users browsing this forum: No registered users and 75 guests

cron