<div dir="ltr"><div class="gmail_default" style="font-family:'comic sans ms',sans-serif">Wanted something like this:</div><div class="gmail_default" style="font-family:'comic sans ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'comic sans ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'comic sans ms',sans-serif">// upside down :(</div><div class="gmail_default" style="font-family:'comic sans ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'comic sans ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'comic sans ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'comic sans ms',sans-serif"><p style="margin:0px">w = 102; //170;</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">//data=[1,2,4,8,16,32,1,2,3,4,5,6,7,8,9,0,16];</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">//data =[32768,16384,8192,4096,2048,1024,512,256,128,64,32,16,8,4,2,1];</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">//data=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768];</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">data0 =[</p>
<p style="margin:0px">9728 ,</p>
<p style="margin:0px">28492 ,</p>
<p style="margin:0px">26734 ,</p>
<p style="margin:0px">24902 ,</p>
<p style="margin:0px">16386 ,</p>
<p style="margin:0px">16386 ,</p>
<p style="margin:0px">16384 ,</p>
<p style="margin:0px">24578 ,</p>
<p style="margin:0px">28930 ,</p>
<p style="margin:0px">16384 ,</p>
<p style="margin:0px">16384 ,</p>
<p style="margin:0px">0 ,</p>
<p style="margin:0px">0 ,</p>
<p style="margin:0px">1124 ,</p>
<p style="margin:0px">1126 ,</p>
<p style="margin:0px">30284 </p>
<p style="margin:0px"> </p>
<p style="margin:0px"><br></p>
<p style="margin:0px">];</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">data1=[0 ,</p>
<p style="margin:0px">26190 ,</p>
<p style="margin:0px">65535 ,</p>
<p style="margin:0px">62431 ,</p>
<p style="margin:0px">61839 ,</p>
<p style="margin:0px">57735 ,</p>
<p style="margin:0px">57735 ,</p>
<p style="margin:0px">24963 ,</p>
<p style="margin:0px">29635 ,</p>
<p style="margin:0px">32767 ,</p>
<p style="margin:0px">60267 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49154 ,</p>
<p style="margin:0px">58370 ,</p>
<p style="margin:0px">58623 ,</p>
<p style="margin:0px">65534 </p>
<p style="margin:0px"><br></p>
<p style="margin:0px">];</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">data2=[49155 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49154 ,</p>
<p style="margin:0px">16387 ,</p>
<p style="margin:0px">16387 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49154 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">49155 ,</p>
<p style="margin:0px">65535 ];</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">data3=[65535 ,</p>
<p style="margin:0px">32767 ,</p>
<p style="margin:0px">32766 ,</p>
<p style="margin:0px">65535 ,</p>
<p style="margin:0px">65535 ,</p>
<p style="margin:0px">65534 ,</p>
<p style="margin:0px">32766 ,</p>
<p style="margin:0px">65535 ,</p>
<p style="margin:0px">65535 ,</p>
<p style="margin:0px">65535 ,</p>
<p style="margin:0px">65535 ,</p>
<p style="margin:0px">32767 ,</p>
<p style="margin:0px">32639 ,</p>
<p style="margin:0px">65534 ,</p>
<p style="margin:0px">65535 ,</p>
<p style="margin:0px">65534 ];</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">data4=[31710 ,</p>
<p style="margin:0px">32222 ,</p>
<p style="margin:0px">31710 ,</p>
<p style="margin:0px">31710 ,</p>
<p style="margin:0px">31710 ,</p>
<p style="margin:0px">31710 ,</p>
<p style="margin:0px">31698 ,</p>
<p style="margin:0px">29658 ,</p>
<p style="margin:0px">31698 ,</p>
<p style="margin:0px">28626 ,</p>
<p style="margin:0px">28626 ,</p>
<p style="margin:0px">28630 ,</p>
<p style="margin:0px">28630 ,</p>
<p style="margin:0px">28630 ,</p>
<p style="margin:0px">28630 ,</p>
<p style="margin:0px">28670 ];</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">//test = chr() -> #0a99f;</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">CubeSize = 4;</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px">MyCube (0,0,10);</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">echo (data);</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px">//color ("RED")</p>
<p style="margin:0px">//{</p>
<p style="margin:0px">// MyCube ( 1, 1, 1);</p>
<p style="margin:0px">// MyCube ( 1, 1,16);</p>
<p style="margin:0px">// MyCube ( 1,16, 1);</p>
<p style="margin:0px">// MyCube ( 1,16,16);</p>
<p style="margin:0px">//</p>
<p style="margin:0px">// MyCube (16, 1, 1);</p>
<p style="margin:0px">// MyCube (16, 1,16);</p>
<p style="margin:0px">// MyCube (16,16, 1);</p>
<p style="margin:0px">// MyCube (16,16,16);</p>
<p style="margin:0px">//</p>
<p style="margin:0px">//}</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">for (k=[0:15])</p>
<p style="margin:0px">{</p>
<p style="margin:0px">color ("Lime") line (0,data0[k],k);</p>
<p style="margin:0px">}</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">for (k=[0:15])</p>
<p style="margin:0px">{</p>
<p style="margin:0px">color ("Green") line (1,data1[k],k);</p>
<p style="margin:0px">}</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">// 12 lines ..</p>
<p style="margin:0px">for (bod=[2:13])</p>
<p style="margin:0px">{</p>
<p style="margin:0px">for (k=[0:15])</p>
<p style="margin:0px">{</p>
<p style="margin:0px">color ("gray") line (bod,data2[k],k);</p>
<p style="margin:0px">}</p>
<p style="margin:0px">}</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px">for (k=[0:15])</p>
<p style="margin:0px">{</p>
<p style="margin:0px">color ("Blue") line (14,data3[k],k);</p>
<p style="margin:0px">}</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">for (k=[0:15])</p>
<p style="margin:0px">{</p>
<p style="margin:0px">color ("DodgerBlue") line (15,data4[k],k);</p>
<p style="margin:0px">}</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">module line (xln,test, zCnt)</p>
<p style="margin:0px">{</p>
<p style="margin:0px"> echo ("data ", test, " count ", zCnt);</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"> bit15 =(( (test - ( 0 )) / 32768 ) >= 1) ? 32768 :0;</p>
<p style="margin:0px"> bit14 =(( (test - ( bit15 )) / 16384 ) >= 1) ? 16384 :0;</p>
<p style="margin:0px"> bit13 =(( (test - ( bit15 + bit14) ) / 8192 ) >= 1) ? 8192 :0;</p>
<p style="margin:0px"> bit12 =(( (test - ( bit15 + bit14 + bit13) ) / 4096 ) >= 1) ? 4096 :0;</p>
<p style="margin:0px"> bit11 =(( (test - ( bit15 + bit14 + bit13 + bit12) ) / 2048 ) >= 1) ? 2048 :0;</p>
<p style="margin:0px"> bit10 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11) ) / 1024 ) >= 1) ? 1024 :0;</p>
<p style="margin:0px"> bit9 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 )) / 512 ) >= 1) ? 512 :0;</p>
<p style="margin:0px"> bit8 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 + bit9 )) / 256 ) >= 1) ? 256 :0;</p>
<p style="margin:0px"> bit7 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 + bit9 + bit8 )) / 128 ) >= 1) ? 128 :0;</p>
<p style="margin:0px"> bit6 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 + bit9 + bit8 + bit7 )) / 64 ) >= 1) ? 64 :0;</p>
<p style="margin:0px"> bit5 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 + bit9 + bit8 + bit7 + bit6 )) / 32 ) >= 1) ? 32 :0;</p>
<p style="margin:0px"> bit4 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 + bit9 + bit8 + bit7 + bit6 + bit5 )) / 16 ) >= 1) ? 16 :0;</p>
<p style="margin:0px"> bit3 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 + bit9 + bit8 + bit7 + bit6 + bit5 + bit4 )) / 8 ) >= 1) ? 8 :0;</p>
<p style="margin:0px"> bit2 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 + bit9 + bit8 + bit7 + bit6 + bit5 + bit4 + bit3 )) / 4 ) >= 1) ? 4 :0;</p>
<p style="margin:0px"> bit1 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 + bit9 + bit8 + bit7 + bit6 + bit5 + bit4 + bit3 + bit2) ) / 2 ) >= 1) ? 2 :0;</p>
<p style="margin:0px"> bit0 =(( (test - ( bit15 + bit14 + bit13 + bit12 + bit11 + bit10 + bit9 + bit8 + bit7 + bit6 + bit5 + bit4 + bit3 + bit2 + bit1 )) / 1 ) >= 1) ? 1 :0;</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px">if (bit15) MyCube (xln, 15,zCnt);</p>
<p style="margin:0px">if (bit14) MyCube (xln, 14,zCnt);</p>
<p style="margin:0px">if (bit13) MyCube (xln, 13,zCnt);</p>
<p style="margin:0px">if (bit12) MyCube (xln, 12,zCnt);</p>
<p style="margin:0px">if (bit11) MyCube (xln, 11,zCnt);</p>
<p style="margin:0px">if (bit10) MyCube (xln, 10,zCnt);</p>
<p style="margin:0px">if (bit9) MyCube (xln, 9,zCnt);</p>
<p style="margin:0px">if (bit8) MyCube (xln, 8,zCnt);</p>
<p style="margin:0px">if (bit7) MyCube (xln, 7,zCnt);</p>
<p style="margin:0px">if (bit6) MyCube (xln, 6,zCnt);</p>
<p style="margin:0px">if (bit5) MyCube (xln, 5,zCnt);</p>
<p style="margin:0px">if (bit4) MyCube (xln, 4,zCnt);</p>
<p style="margin:0px">if (bit3) MyCube (xln, 3,zCnt);</p>
<p style="margin:0px">if (bit2) MyCube (xln, 2,zCnt);</p>
<p style="margin:0px">if (bit1) MyCube (xln, 1,zCnt);</p>
<p style="margin:0px">if (bit0) MyCube (xln, 0,zCnt);</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">}</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px">module MyCube (xx,yy,zz)</p>
<p style="margin:0px">{</p>
<p style="margin:0px"> translate ([xx*CubeSize, yy*CubeSize, zz*CubeSize]) cube (CubeSize);</p>
<p style="margin:0px">}</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 30, 2014 at 1:48 PM, Justin Mitchell <span dir="ltr"><<a href="mailto:justin@discordia.org.uk" target="_blank">justin@discordia.org.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, 2014-10-30 at 13:37 +0000, Ceri Clatworthy wrote:<br>
> Hi, going crazy here ...<br>
> I need something like:<br>
<br>
> test = 102; // 0x66<br>
> if (test AND 1) {do something usefull @ poz 1};<br>
> if (test AND 2) {do something usefull @ poz 2};<br>
<br>
</span><span class="">> e.g. draw the binary representation of a 16 bit number in<br>
> cubes/spheres !!!<br>
<br>
</span>Doesn't look possible,<br>
there are no bitwise operators that i can see, and<br>
variables are evaluated at compile time so you cant even run a loop to<br>
do it the long way around.<br>
<br>
Either preprocess it, i.e. write a program that writes openscad.<br>
or switch to openjscad which is an almost identical syntax except that<br>
it uses javascript as the language, so can do less noddy operations<br>
<br>
<br>
<br>
_______________________________________________<br>
Hackspace mailing list<br>
<a href="mailto:Hackspace@swansea.hackspace.org.uk">Hackspace@swansea.hackspace.org.uk</a><br>
<a href="http://swansea.hackspace.org.uk/mailman/listinfo/hackspace" target="_blank">http://swansea.hackspace.org.uk/mailman/listinfo/hackspace</a><br>
</blockquote></div><br></div>