<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Rounding Lengths UP/Down in GDL in Libraries &amp; objects</title>
    <link>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295400#M2457</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;T&gt;Hi every one,&lt;BR /&gt;
&lt;BR /&gt;
I would like to know if there is a hidden function in GDL to round up or down a length parameter ?&lt;BR /&gt;
&lt;BR /&gt;
if not, what is the best way to implement it ?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance&lt;/T&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 09 Apr 2019 05:08:41 GMT</pubDate>
    <dc:creator>Nader Belal</dc:creator>
    <dc:date>2019-04-09T05:08:41Z</dc:date>
    <item>
      <title>Rounding Lengths UP/Down in GDL</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295400#M2457</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;T&gt;Hi every one,&lt;BR /&gt;
&lt;BR /&gt;
I would like to know if there is a hidden function in GDL to round up or down a length parameter ?&lt;BR /&gt;
&lt;BR /&gt;
if not, what is the best way to implement it ?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance&lt;/T&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Apr 2019 05:08:41 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295400#M2457</guid>
      <dc:creator>Nader Belal</dc:creator>
      <dc:date>2019-04-09T05:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Lengths UP/Down in GDL</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295401#M2458</link>
      <description>MOD is the operator you are looking for.&lt;BR /&gt;
&lt;BR /&gt;
length MOD module&lt;BR /&gt;
&lt;BR /&gt;
i.e. 2.9 MOD 0.3&lt;BR /&gt;
&lt;BR /&gt;
This will give you the remaining part of the module (0.2 in this case).&lt;BR /&gt;
&lt;BR /&gt;
So to round down .... 2.9-(2.9 MOD 0.3)&lt;BR /&gt;
&lt;BR /&gt;
And to round up ... 2.9-(2.9 MOD 0.3) + 0.3&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Or you could do it the long way using INT and FRA&lt;BR /&gt;
Divide the length by the module and this will give you a decimal number.&lt;BR /&gt;
&lt;BR /&gt;
INT of that number is the total number of whole modules.&lt;BR /&gt;
FRA of that number is fractional part of the remaining module length.&lt;BR /&gt;
&lt;BR /&gt;
If the FRA is greater than 0 then round up by (INT+1) x module length&lt;BR /&gt;
To round down is simply INT x module length.&lt;BR /&gt;
&lt;BR /&gt;
Barry.</description>
      <pubDate>Tue, 09 Apr 2019 05:45:43 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295401#M2458</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2019-04-09T05:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Lengths UP/Down in GDL</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295402#M2459</link>
      <description>Thank you Barry, that is extactly what I was searching for</description>
      <pubDate>Tue, 09 Apr 2019 06:03:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295402#M2459</guid>
      <dc:creator>Nader Belal</dc:creator>
      <dc:date>2019-04-09T06:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Lengths UP/Down in GDL</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295403#M2460</link>
      <description>You should have a look at &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;CEIL (x)&lt;E&gt;&lt;/E&gt; and &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;ROUND_INT (x)&lt;E&gt;&lt;/E&gt; functions. Depending on what you are trying to round, these can be useful.</description>
      <pubDate>Thu, 18 Apr 2019 16:19:33 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295403#M2460</guid>
      <dc:creator>Durval</dc:creator>
      <dc:date>2019-04-18T16:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Lengths UP/Down in GDL</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295404#M2461</link>
      <description>&lt;BLOCKQUOTE&gt;Barry wrote:&lt;BR /&gt;
And to round up ... 2.9-(2.9 MOD 0.3) + 0.3
&lt;/BLOCKQUOTE&gt;

You may have problems with this. Suppose you want to round up 2.7. It's already rounded, so the correct value should be 2.7, but your code would generate 3.0 as rounded up value.</description>
      <pubDate>Thu, 18 Apr 2019 16:37:30 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295404#M2461</guid>
      <dc:creator>Durval</dc:creator>
      <dc:date>2019-04-18T16:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Lengths UP/Down in GDL</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295405#M2462</link>
      <description>&lt;BLOCKQUOTE&gt;Durval wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;Barry wrote:&lt;BR /&gt;
And to round up ... 2.9-(2.9 MOD 0.3) + 0.3
&lt;/BLOCKQUOTE&gt;

You may have problems with this. Suppose you want to round up 2.7. It's already rounded, so the correct value should be 2.7, but your code would generate 3.0 as rounded up value.
&lt;/BLOCKQUOTE&gt;

&lt;BR /&gt;
Very true.&lt;BR /&gt;
Pretty obvious I am not a particularly good coder.&lt;BR /&gt;
Code first then fix the problems when you don’t get the result you want - that’s the way I tend to work.   &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_lol.gif" style="display : inline;" /&gt; &lt;BR /&gt;
&lt;BR /&gt;
Barry.</description>
      <pubDate>Sun, 21 Apr 2019 11:31:58 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295405#M2462</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2019-04-21T11:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Lengths UP/Down in GDL</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295406#M2463</link>
      <description>@Durval thank you, but I have already weight these two solutions and they didn't fit my needs.&lt;BR /&gt;
&lt;BR /&gt;
I explain: &lt;BR /&gt;
The problem is that I have a panel with predefined total fixed widths, composed of 2 outer layers and and a frame, and the user have the ability to choose a unified skin thickness from &lt;B&gt;0mm&lt;/B&gt; to &lt;B&gt;0.5*panel_thickness&lt;/B&gt;, with the condition that it must be rounded mm with &lt;B&gt;NO FRACTIONS&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
So as long the panel thickness forms an even number there will be no problem, ex:&lt;BR /&gt;
panel 100mm --- forms ---&amp;gt; skin thickness range [0, 50mm]&lt;BR /&gt;
&lt;BR /&gt;
But if the panel thickness is an odd number:&lt;BR /&gt;
panel 125 --- forms ---&amp;gt; skin thickness range [0, 62.5mm]       !&amp;lt;--- that is what I´m trying to prevent&lt;BR /&gt;
&lt;BR /&gt;
Let's study your solutions:&lt;BR /&gt;
CEIL (x)&lt;BR /&gt;
Returns the smallest integral value that is not smaller than x (always integer). (copy pasted from GDL manual)&lt;BR /&gt;
&lt;BR /&gt;
panel 125 --- forms ---&amp;gt; skin thickness range [0, ceil(125*0.5)] will get you a range [0, 63]&lt;BR /&gt;
&lt;BR /&gt;
but 63*2 = 126 mm panel (error - not acceptable)&lt;BR /&gt;
&lt;BR /&gt;
ROUND_INT (x)&lt;BR /&gt;
Returns the rounded integer part of x.&lt;BR /&gt;
&lt;BR /&gt;
in other words, and using the previous example 62.5 mm will be rounded to 63 mm (error - not acceptable)&lt;BR /&gt;
&lt;BR /&gt;
On the other hand @Barry's solution may have been wrong, but it pointed out where I needed to go, so I modified his solution in a way that it will fulfill my needs, and not prone to errors it the units used in the template is changed by writing this psuedo_code in GDL&lt;BR /&gt;
&lt;BR /&gt;
values "skin_thickness" , range (0, (0.5*panel_thickness) - (panel_thickness * 0.5 MOD 0.001) )&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
So thank you all, if it wasn't for you I wouldn't have been able to get this solution</description>
      <pubDate>Mon, 22 Apr 2019 11:48:56 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295406#M2463</guid>
      <dc:creator>Nader Belal</dc:creator>
      <dc:date>2019-04-22T11:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Lengths UP/Down in GDL</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295407#M2464</link>
      <description>&lt;BLOCKQUOTE&gt;Moonlight wrote:&lt;BR /&gt;
values "skin_thickness" , range (0, (0.5*panel_thickness) - (panel_thickness * 0.5 MOD 0.001) )
&lt;/BLOCKQUOTE&gt;

I'm glad you found a solution!</description>
      <pubDate>Mon, 22 Apr 2019 12:52:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Rounding-Lengths-UP-Down-in-GDL/m-p/295407#M2464</guid>
      <dc:creator>Durval</dc:creator>
      <dc:date>2019-04-22T12:52:12Z</dc:date>
    </item>
  </channel>
</rss>

