so there is suppose to be a constant that shows the total number of values to be shown in this range. The user enters two values, lets say userMin is -2 and userMax is 2, it's suppose to add 0.2 to -2 and so on until it reaches 2. It starts doing that up until it reaches -1.0, then it goes to -0.9, -0.7.... etc, It also goes beyond 2, which i think is because the incrementation is wrong. Any ideas?
can you explain why that happens with 20 instead of 21. i also put a break in the nested loop to stop it at 2. if i dont itll keep going past it.
Edit: the constant has to match up with the total number of values
Well that ain't right. The x should increase by 0.2. Small rounding errors won't account for these large differences so something is clearly wrong with the increment value. Looking at the code I see a fence post problem. If you divide the range from -2 to 2 into intervals 0.1 wide, then you get 21 values, but only 20 intervals. So let's change line 22 to float inc = (userMax-userMin)/(SIZE-1);
Much better! The highlighted value might appear wrong, but it's really just a number very close to zero. If you uncomment line 9 you'll get the right output: