Re: Bitwise strangeness
Posted: Thu Feb 18, 2016 11:34 am
If you can avoid it, do it. It's basically the slowest math operator... Only some functions (eg. log10, exp, pow) are slower.
DSP Robotics and FlowStone Graphical Programming Software Support and Forums
http://dsprobotics.com/support/
MyCo wrote:If you can avoid it, do it. It's basically the slowest math operator... Only some functions (eg. log10, exp, pow) are slower.
pos = index-(index%1);
pos = int(index);
y = rndint(x-0.49999991);
MyCo wrote:for old versions you can use
- Code: Select all
y = rndint(x-0.49999991);
for truncation, it works as long as x >=0
rndint(0-0.49999991)
Nowhk wrote:I see (I always think 0.5 was the correct scaling)
Nowhk wrote:return -0 and not 0? On Some "display" value that's weird.
MyCo wrote:0.5 would round integer numbers down too, eg. 2 would round down to 1
int(1.5);
rndint(1.5)
MyCo wrote:Yeah, floating point system has two zeros, so the sign of the input is carried through the operation
streamout o1;
streamout o2;
float x = 1;
o1 = rndint(x - 0.49999991);
o2 = rndint(x - 0.5);
MyCo wrote:That's not what I meant, try this to see the difference:
- Code: Select all
streamout o1;
streamout o2;
float x = 1;
o1 = rndint(x - 0.49999991);
o2 = rndint(x - 0.5);
MyCo wrote:Seems to depend on the CPU: