Page 1 of 1
rounding cycle interrogation ?..
Posted: Mon Mar 21, 2022 5:16 pm
by Tepeix
Just a simple float counters.
Every time it go > 4096 it's get - 4096.
(seams to works well but not if the input value is > 4096... I need to test it more..)
What seams strange is the first cycle with an 0.1 input value will make 0.1 when -4096 occurs.
Then next cycle it become 0.449. then 0.0347. then 0.0244, 0.0142, 0.0039, ... ...
Did you know what cause this strange rounding behavior ?
Is there any use to try to fix this ?
Thanks for any response

Re: rounding cycle interrogation ?..
Posted: Mon Mar 21, 2022 7:25 pm
by Tepeix
I try a different approach with this code :
Code: Select all
streamin in;
streamout out;
float index=0;
float max=4096;
movaps xmm0,in;
addps xmm0,index;
movaps xmm1,xmm0;
cmpps xmm1,max,5;
andps xmm1,max;
subps xmm0,xmm1;
movaps index,xmm0;
movaps out,xmm0;
But i get exatly the same result ... ..
Re: rounding cycle interrogation ?..
Posted: Mon Mar 21, 2022 9:31 pm
by Tepeix
Another approach...
This time a float ramp from 0 to 1. That feed a int counter from 0 to 4095..
And finally the added result.
That's a little more stable. But it never go to 0.. Or maybe after a long time ?
The max value change a little. A 0.0005 imprecision for both..
Also if i check the counter.. There's a lot of variation after 0.1. Like it always add something like 0.10001 ?
Re: rounding cycle interrogation ?..
Posted: Mon Mar 21, 2022 10:11 pm
by Tepeix
Finally, this one seams to works with no rounding problems. (at least for 0.1 input !)
The float ramp go from -0.5 to 0.5. > feed the int counter.
Then adding 0.5 to the float. Adding the int. It seams ok for now

(Note that this code and the last one have a blue int output.
If you connect it to a code that treat it as a float it will take cpu and give bad result..)
Re: rounding cycle interrogation ?..
Posted: Wed Mar 23, 2022 12:59 am
by tulamide
I'm not sure, what goal you try to reach?
float values are imprecise by nature, you can't rely on them. If you want to make sure to get a stable start and end point, you have to use linear interpolation. If you try to get exact steps per sample, you need to use integer numbers (note, integer numbers, not the integer format). In other words steps like +1 or +13, instead of 0.1 or 1.3.
Re: rounding cycle interrogation ?..
Posted: Wed Mar 23, 2022 1:11 pm
by Tepeix
Thanks !
I was thinking that float would be imprecise when using very small number but not specially with 0.1.
Not really sure what i try to do.. But the main purpose is an lfo reading mem.
Maybe an osc, but i think it would be impossible to bandlimit it..
Maybe for an lfo i don't need so much precision...
The 4096 choice also could be to much..
But the int think attract me

I first try with true int then i read again your message

Re: rounding cycle interrogation ?..
Posted: Wed Mar 23, 2022 6:33 pm
by Tepeix
Héhé, the guy that try to utilize green ticker to blue, then complain about blue float precision
