Hi,

I’m working on a pattern that involves working out angles around a circle. Most of the code is irrelevant here so I’ll just focus on this very (imo) strange behavior.

points = 8

angle = 360/points

for t = 0, 360-angle, angle do

print (t)

end

This piece of code prints out the angles equally spaced around a circle, based on number of points on circumference. So for example, if points = 8, angle will be 45, and printout will be 0, 45, 90, 135, 180, 225, 270, 315. Now for some reason, certain point values fail to print out the last angle e.g. 13, 17, 26. I thought at first it may be primes but 26 isn’t and 19 & 23 work ok.

I wondered if it was some sort of rounding discrepancy, and made this slight change…

for t = 0, 360-angle+0.0001, angle do

and it now ‘mostly’ works. However, the addition of 0.0001 fails to fix points = 26. But change it to 0.001 and that now works. So is some sort of threshold involved too?

Hope someone can shed some light on what is going on.

Many thanks,

David