Can be done even more economically...
Streambool to Stream.osm
CoreStyler wrote:Exactly what i was thinking... if input < 1 or >1 then bool T or F
This is not quite how Stream Booleans work...
From code/assembly, you may be familiar with the idea of comparisons making a bitmask...
e.g.
(x>0) & value ;result is zero if x<=0 or you get
value if x>0.
If false, a comparison yields zero (all bits to 0)- if it is true you get a value where all bits are set to one.
The true result (all bits 1), doesn't really represent any particular number - it is just convenient so that you can use bitwise logic (e.g.
& value) to mask or unmask the bits in other variables and numbers.
StreamBools (poly or mono) carry these bitmasks rather than true numbers, and let you pass them around your schematic to avoid the need for extra comparisons later on - so in my example schematic, I can use a streamboolin (instead of streamin) and then just a single
& to turn the value into zero or one. (naturally, there is a 'streamboolout equivalent).
Within code blocks, you can use a similar idea to "share" a comparison between lots of statements.
e.g. instead of
- Code: Select all
a = a & (x>0);
b = b & (x>0);
c = c & (x>0);
...you can do this instead...
- Code: Select all
bigx = (x>0); /store the bitmask
a = a & bigx;
b = b & bigx;
c = c & bigx;
An extra line of code, but you save the CPU of repeating the comparison - and in assembly this can be even more economical, as the bitmask can be kept in a register rather than a variable.
Note that this is very different to "green" booleans - they are either zero or one (you can see this if you connect a green bool to a float or integer). If you convert a float or integer direct to green boolean, then
any non-zero value counts as true.
You do not have the required permissions to view the files attached to this post.