# for statement doesn't do all the steps sometimes

39 messages
12
Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

 In reply to this post by doug.moen On Sat, Dec 17, 2016 at 11:16:40AM -0500, doug moen wrote: > My implementation accounts for floating point imprecision: the 'last' value > might be an approximation of the final value. So [1 : 0.2 : 2.99] and [1 : > 0.2 : 3.01] produce the same result as [1 : 0.2 : 3]. Auch!  I know that steps of 0.2 are "inaccurate" and "compensation for floating point inaccuracies may be necessary". But if I want N steps where the step size is never smaller than 0.01, and I do NOT want to include the final object at index "3", I'll write: [1:3/N:2.99] to make sure that the final one will NOT be rendered. Fixing the "assumption" that 3/N is never < 0.01, I'll write: [1:3/N:3-1/N], again to make sure that I don't include the final one at (floating point accuracy equal to) 3. This is important if, say I'm building a fence: N=4; eps=0.1; for (i=[0:1/N:3-eps]) translate ([i,0,0]) cube ([0.1,0.1,1]); for (i=[0:1/N:1-eps]) translate ([3,i,0]) cube ([0.1,0.1,1]); for (i=[4:1/N:5-eps]) translate ([i,1,0]) cube ([0.1,0.1,1]); The final values each time are meant NOT to be included each time, otherwise I get a double post at those points.         Roger. -- ** [hidden email] ** http://www.BitWizard.nl/ ** +31-15-2600998 ** **    Delftechpark 26 2628 XH  Delft, The Netherlands. KVK: 27239233    ** *-- BitWizard writes Linux device drivers for any device you may have! --* The plan was simple, like my brother-in-law Phil. But unlike Phil, this plan just might work. _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

 In reply to this post by doug.moen On Sun, Dec 18, 2016 at 12:37:41PM -0500, doug moen wrote: > If we fix this bug, we will likely be fixing bugs in a lot of existing > models, But if you suddenly change behaviour for endvalues = X * start+step, where X = n + [0.5...1]; you will also create bugs in other existing models. An automatic epsilon of around step / 2^(mantissa_size - 4) sounds reasonable to me. Mantissa_size is 24 or 23 for floats, and 48 for doubles. This will keep the published behaviour unless you're doing on the order of 2^20 steps....         Roger. -- ** [hidden email] ** http://www.BitWizard.nl/ ** +31-15-2600998 ** **    Delftechpark 26 2628 XH  Delft, The Netherlands. KVK: 27239233    ** *-- BitWizard writes Linux device drivers for any device you may have! --* The plan was simple, like my brother-in-law Phil. But unlike Phil, this plan just might work. _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

 An easier way is to increase your end value by 1/2 the step size. Larry
Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

 On 20. des. 2016 17:42, Tim V. Shaporev wrote: > Any value which can be represented in decimal notation can be > represented as rational number exactly. Try an irrational number, try PI (Hint: 22/7 is not the answer). This whole discussion is bizarre. Carsten Arnholm _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

 >From: Discuss [[hidden email]] on behalf of Carsten Arnholm [[hidden email]] >On 20. des. 2016 17:42, Tim V. Shaporev wrote: >> Any value which can be represented in decimal notation can be >> represented as rational number exactly. >Try an irrational number, try PI (Hint: 22/7 is not the answer). As soon as you give me exact decimal writing of PI (Hint: 3.14 is not the answer). >This whole discussion is bizarre. Agree. Bye Tim _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

 SQRT(2.0)On Dec 20, 2016, at 13:48, Shaporev, Timur <[hidden email]> wrote:From: Discuss [[hidden email]] on behalf of Carsten Arnholm [[hidden email]]On 20. des. 2016 17:42, Tim V. Shaporev wrote:Any value which can be represented in decimal notation can berepresented as rational number exactly.Try an irrational number, try PI (Hint: 22/7 is not the answer).As soon as you give me exact decimal writing of PI (Hint: 3.14 is not the answer).This whole discussion is bizarre.Agree.ByeTim_______________________________________________OpenSCAD mailing list[hidden email]http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org —Kenneth Sloan[hidden email] _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

 In reply to this post by cacb I agree absolutely with you, Carsten. A lot of people have no clue about internal representation of numbers. Just my \$0.02, Jean-Paul N1JPL > On Dec 20, 2016, at 1:31 PM, Carsten Arnholm <[hidden email]> wrote: > > On 20. des. 2016 17:42, Tim V. Shaporev wrote: >> Any value which can be represented in decimal notation can be >> represented as rational number exactly. > > Try an irrational number, try PI (Hint: 22/7 is not the answer). > > This whole discussion is bizarre. > > Carsten Arnholm > > _______________________________________________ > OpenSCAD mailing list > [hidden email] > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: for statement doesn't do all the steps sometimes

Open this post in threaded view
|