divremcPend

divide integer with constant, also outputs remainder (modulo). Uses integer input to set denominator
Author: Johannes Taelman, changed by Remco van der Most
License: BSD
Github: sss/math/divremcPend.axo

Inlets

int32 nominator

int32 denominator

Outlets

int32 remainder of division by denominator

int32 a divided by denominator

Parameters

bool32.tgl pendulum

Control Rate
int r;
int denominator = inlet_denominator * (1 + param_pendulum);
if (inlet_a >= 0)
  r = ((unsigned int)inlet_a) / denominator;
else
  r = -(((unsigned int)(denominator - inlet_a)) / denominator);
outlet_div = r;
r = inlet_a - (r * denominator);
outlet_rem = r > inlet_denominator ? (inlet_denominator << 1) - r : r;

Privacy

© 2024 Zrna Research