On Tue, Jul 24, 2018 at 04:51:21PM +0300, Ruslan Kabatsayev wrote:
Hi,
On 24/07/2018, Andrew Eikum aeikum@codeweavers.com wrote:
On Mon, Jul 23, 2018 at 10:51:49PM +0300, Ruslan Kabatsayev wrote:
Just curious, which cases does this fix? The ones when fabs(cos)>1 due to rounding errors? Or is acos broken for arguments near but not exceeding ±1?
Pretty sure it's rounding errors that result in fabs(cos)>1. That causes acos to return NAN, and bad things happen to audio volumes. I'd be surprised if acos is broken like the 2nd case you mention.
Then why not check for the condition explicitly instead of introducing an arbitrary "tolerance" constant and working in symmetric neighborhoods of ±1? I.e. I suggest using `cos>1` condition in the first 'if' and `cos<-1` in the second one. IMHO it'd be easier to understand for a casual reader. (This will change behavior in the cases of |cos|≫1, but we aren't trying to guard against them, are we?)
Yeah, that makes sense, thanks for the suggestion. I'll re-send.
Andrew