>= output only 1's ??
hello :)
the '>=' object outputs a '1' when greater than or equal too; and then a 0 when less than.
is there a way to make this obect only output a '1'? Maybe by converting all the 0's to 1's? or to filter out the 0's ...or maybe route all the 0's away?
i searched the msp tutorials with no luck so far.
sorry for being so new. lol :P
If you convert all the 0's to 1's I don't really see the point of the >= 1.
You could use [route], but [select] is more often used for this.
If you just want input above 1., you can also use [split], which will send out the input as well.
Oh, and look in the Max tutorials, not the MSP ones.
teqy wrote on Tue, 02 June 2009 06:28hello
or maybe route all the 0's away?
yes, that can do the trick :
Ch.
hi thanks for the help.
sorry i meant convert '1' to a '0'
in my patch i have a '1' being creted amounst lots of 0's
ive been able to route the 1 away now, but need to convert this 1 into a 0. ( so i can turn something off with it)
is there an object like (1 = 0) so 1 becomes a 0 ?
thanks i shall be reading up on these tutorials and the youtube baz tutoriala too.(they are great)
peace:)
wow thanks tim. you rule too
One more suggestion in the box:
I seem to have an aversion to [if ... then...] statements and I usually would do a conversion of this kind like this:
nice one ! wow, so many ways to do the same thing.
msp is emense.
well, technically we have only been dealing with Max so for...
MIB wrote on Tue, 02 June 2009 12:17One more suggestion in the box:
I seem to have an aversion to [if ... then...] statements and I usually would do a conversion of this kind like this:
[!- 1] (as suggested by timlloyd) do the same.
By the way, I would really like a 'not' operator in max, which would output '10011' for a '01100' input for example. There's no object like that right?
[!&] for nand and [!|] for nor would be fine as well.
just a suggestion for the v6.
ch.
but the most common/simple way hasn't shown up yet: [== 0]...
you might also want to look at [change] to filter out repetitions...
Stefan
The lobjects has an object called ! which will perform a NOT operation on lists.
Ch wrote on Tue, 02 June 2009 17:46
By the way, I would really like a 'not' operator in max, which would output '10011' for a '01100' input for example. There's no object like that right?
[!&] for nand and [!|] for nor would be fine as well.
just a suggestion for the v6.
ch.
you could take a list and use [iter], then an [if] to change 1 to 0 and vice-versa, or a [sel 0 1] --> to message boxes that read 1 0. collect back into a list with [append] to a message box, or [zl group]. I don't know a direct operator for "not" in binary lists, except the LObjects one mentioned.
Also if you store the incoming lists into toggles, bangs will "not" them, but this might be kludgy and you'd have a maximum list size. with [iter] the list can be as long as you like, just do a [zl len] before you iter to get the length of the list, then that sets the [zl group] size. Doubtless there are even simpler ways too.
but... 10010 is not a list!
Anyway, you're right there's many way to do it.
It was really just a suggestion to complete the bitwise operators collection.
And with more and more people using arduino or something, I think that could be usefull.
Ch.
For lists [vexpr 1-$i1] will swap ones and zeros if scalar mode is turned on, much like [!] from Lobjects.
lh
[quote title=Ch wrote on Wed, 03 June 2009 00:46]MIB wrote on Tue, 02 June 2009 12:17By the way, I would really like a 'not' operator in max, which would output '10011' for a '01100' input for example. There's no object like that right?
There is, but you have to think about the number of digits you want to incorporate. You can use [* -1] and substract 1. Negative numbers are represented with a ! on every bit. You can use that if you are fine with 32 bits. You might add some logical masks to get other negations...
Stefan
Nice one Stephan,
But you'll agree that you not working with binary numbers.
There are displayed, but not used.
But I think this is the easiest way to work with binary numbers :
convert them in decimal - do what you want - convert back to binary.
But there's no (built in) easy way to convert a decimal to binary right?
Another thing that I would like (sorry about all my wishes) is a third outlet for [number], that would output what is displayed as a symbol. I could be usefull if you want to use the midi values to name some files for example, or to convert decimal to binary..
Does that makes sense?
Charles
Here's a little javascript that changes the format of a symbol or number into a different numeral system. The arguments set the incoming and outgoing bases respectively. It goes from 1 (a tally) up to 36 (0-9 a-z) but you could extend it to use punctuation or capitals if you needed.
lh
// numeral.js
var inb = jsarguments[1] || 16;
var outb = jsarguments[2] || 10;
function anything() {
everything = arrayfromargs(messagename, arguments);
outlet(0,parseInt(everything[0],inb).toString(outb));
}
function basein(x) {
inb = Math.min(Math.max(1,x),36);
}
function baseout(x) {
outb = Math.min(Math.max(1,x),36);
}
// EOF
Only one javascript line.. but what a line!
Thanks a lot lh !
Charles
Ch wrote on Mon, 15 June 2009 11:48But you'll agree that you not working with binary numbers.
There are displayed, but not used.
I'd say a number is a number is a number. Each time you use a number you also use its binary form.
Have a look at all binary operators. Its easy to mask any bit with &, you can also use a radiogroup in flagmode. Extend the patch to your liking, encapsulate and you got your object...
Stefan
Just to say we forgot to mention the binary operator ~ that can be used in expr or vexpr : [expr ~$i1]
(it will do the same as [* -1]->[- 1] that stephan suggested in its first patch of course).
edit :
and ^ for nand is supported as well