If statement+counter not working with if(val == 1)

Paolo Piaser's icon

Hello,

as for title, I am trying to get a if statement work when counter reaches a specific value, but it is not happening.
What am I missing? Is it the reason the pulse and flag happens only when origin/end is passed?

Max Patch
Copy patch and select New From Clipboard in Max.


Roman Thilenius's icon

int/float?

Paolo Piaser's icon

I am working in gen~

Dimitri Aatos's icon

You can't rely on floating-point numbers being accurate, this is true for all programming languages. count will probably never be exactly equal to 1. Try using if(count >=1) instead.

Paolo Piaser's icon

Ah, maybe I get what you meant Roman.

I tried with integers under suggestion of a user in facebook group. It works.

Max Patch
Copy patch and select New From Clipboard in Max.

Dimitri Aatos's icon

Yes, also avoiding floating-points works.

Paolo Piaser's icon

Hi Dimitri,
sorry I missed your answer before writing. Yeah, I wanted to avoid the >= for specific reasons (I am triggering events at reset, thus I want it to be precise).