Convert from fractional to boolean with code?


#1

Hello :slight_smile:

I need a little help with a simple coding thing. I'd like to convert a bipolar fractional to a boolean. I have patched this up with factory objects:

It takes in a bipolar fractional... And it sends out a boolean. But when I look inside the object, I only see this:

outlet_o= inlet_i;

It seems like it is the outlets and inlets that converts the signal to boolean, not the code inside the object.

My question is: How would I write that in code, the conversion from fractional to boolean?

Thanks, Jaffa


#2

Ahh found out:

">0 ;"


#3

If I'm not mistaken, it should be !=0
like this:
myBool = (myFrac != 0)


#4

Thanks Ill test that too.

The <0 turns the negative values of the bipolar signal to off and the positive values is on. This is what I'd like, so all good here :wink:


#5

Yes, that makes sense for most applications. I just added my comment because in C/C++ anything !=0 is evaluated as true. So for a straight replication of the factory object's behaviour, you'd have to stick to the !=0 approach.


#6

Yes thanks :slight_smile: Gonna try it out and see how it works anyway :wink: