sambean ·
Just noticed..
rndint(x - 0.5);
doesn't seem to be working in my code as it should..
I'm having to use
temp1 = x - 0.5; rndint(temp1);
Keep up the good work!
Sam
From the original SynthMaker forum (2004–2014), with its members’ names and dates.
sambean ·
Just noticed..
rndint(x - 0.5);
doesn't seem to be working in my code as it should..
I'm having to use
temp1 = x - 0.5; rndint(temp1);
Keep up the good work!
Sam
Shifrin ·
Umm, excuse me for saying this, but rndint(x - 0.5) would take an input of say 3.33 and round it to 2 (i.e. 3.33 - 0.5 = 2.83, truncated to 2) - is that what you're wanting to do?! (If yes I'd be interested to see why 😉)
Oh yeah, I seem to remember having the same problem as the one you just described!
Shif.
sambean ·
Hi Shif,
Sorry, I misread your last post in the other thread.. I thought you said it would be round to the nearest integer..
I did a bit of investigating though and I think this is the case,
If you have some code like
x = x + 0.1; xint = rndint(x); xfrac = x - xint; out = xfrac;
and analyse the output, you get both positive and negative numbers.
This suggests that x is being rounded to the nearest integer, and not down (rounding down should only give only positive numbers..)
I may be wrong though, it would be good to get some clarification..
This hovever separate from the
rndint(x - 0.5);
issue, which I think may be a bug..
Cheers
Sam
Shifrin ·
sambean wrote: If you have some code like
x = x + 0.1; xint = rndint(x); xfrac = x - xint; out = xfrac;
and analyse the output, you get both positive and negative numbers.
This suggests that x is being rounded to the nearest integer, and not down (rounding down should only give only positive numbers..)
Ah, I see, according to the synthmaker docs rndint(a) Rounds to the nearest integer value below. So it seems the docs are wrong!
Now I see why you subtract 0.5, I do the same in some assembler code I wrote to calculate pow(x,n) when I needed to truncate (round down).
Just checked it myself, SM's rndint(N) functions is indeed rounding to the nearest integer and *NOT* rounding down to the nearest integer. SM docs are wrong 😉
Shif.
malc ·
Shifrin wrote: So it seems the docs are wrong!
😮 surely not 😉
Will correct at the very next opportunity. Apologies for the confusion.
Shifrin ·
Cheers malc 😉
Shif.
Mue ·
sambean wrote: Just noticed..
rndint(x - 0.5);
doesn't seem to be working in my code as it should..
I'm having to use
temp1 = x - 0.5; rndint(temp1);
Keep up the good work!
Sam
Now the rndint-function definetely rounds to the nearest integer, but the upper description seems still to be true, unfortunately. If the argument of the function is an operation itsself the result seems to pass the rndint-function without any effect.
The last two lines produce the same result of x = 1.8 in my test codes:
float x; x = 2.3; x = rndint(x - 0.5); x = x - 0.5;
Wrote something here? To have a post removed or your name hidden, write to [email protected].