Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour of ba.if with fractional conditions < 1. #36

Open
dariosanfilippo opened this issue May 9, 2020 · 1 comment
Open

Comments

@dariosanfilippo
Copy link
Contributor

Hello, people.

I believe that, in C/C++ and perhaps all other languages, 0 is false and any non-zero is true.

ba.if(.5, 1, 0); returns 0. I suggest rewriting ba.if as:

if(cond,then,else) = ceil(cond),else,then:select2; .

Also, I find the comments in the code deceiving as it can be used to avoid NANs at run-time, as in the case of:

division(x1, x2) = ba.if(x2 == 0, 0, x1/x2); .

Best,
Dario

@dariosanfilippo
Copy link
Contributor Author

Also, I'd say that select2 should have the same behaviour and any non-zero condition should output the second signal.

Dario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant