Skip to content

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

@dariosanfilippo

Description

@dariosanfilippo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions