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

BinaryOpUGen 'div' operator: off-by-one and not integer division #907

Closed
jamshark70 opened this issue Jul 13, 2013 · 2 comments
Closed

BinaryOpUGen 'div' operator: off-by-one and not integer division #907

jamshark70 opened this issue Jul 13, 2013 · 2 comments
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: server plugins

Comments

@jamshark70
Copy link
Contributor

'div' in the language means integer division: both operands are truncated to integers, and then the quotient is also truncated.

In the server, (a div: b) == ((a / b) + 1), which makes no logical sense whatsoever.

a = {
    var t = Impulse.kr(2),
    c = PulseCount.kr(t),
    x = (c - 5) * 0.25;
    [x, x div: 1].poll(t);
    FreeSelf.kr(c >= 10);
    DC.ar(0);
}.play;

Reasonable to expect a div: b in the server to be compatible with that in the language.

@jamshark70
Copy link
Contributor Author

Correction: it seems actually to be (a div: b) == ((a / b) + b)

@timblechmann
Copy link
Contributor

apparently, integer division is not implemented at all, falling back to the default binary operator, the addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: server plugins
Projects
None yet
Development

No branches or pull requests

2 participants