Go Back   Cockos Incorporated Forums > Projects > Deprecated REAPER issue tracker > Closed Issue

spl0==0 ? (log(0) != log(spl0) ? BUGs += 1;); Issue Tools
issueid=1158 09-09-2009 12:26 AM
spl0==0 ? (log(0) != log(spl0) ? BUGs += 1;);
JS: log() issue

Try that JS (without transport play):

desc:log() issue
spl0==0 ? (log(0) != log(spl0) ? BUGs += 1;);
you can see that the nb of "BUGs" is incremented, it shouldn't...
note: only occurs with "splx" system vars, in the following code, "BUG2" is never incremented:

a=0; log(0) != log(a) ? BUG2s += 1;
Issue Details
Issue Type Closed Issue
Project Deprecated REAPER issue tracker
Category Plugins
Status Live With It For Now
Priority 5 - Medium
Affected Version 3.104
Closed Version (none)
Yes votes 0
No votes 0
Assigned Users (none)
Tags JS, JS FX

09-09-2009 12:55 AM
Human being with feelings
Floating point. 'Nuff said...
09-09-2009 02:13 AM
Human being with feelings
splx has an init value of 5e-17 for denormal prevention (common speculation)

while the amount of accuracy is by design:
true = 0;
spl0 == 0 ? true = 1; // true = 1, while spl0 is 5e-17
(edit) 5 decimal places:
a = 5*10^-5;
b = 4*10^-5;
c = 0;
a == b ? c = 1; 
//c is 1
//* 10e-4 -> c = 0
with log(0)=0 [0 instead of 1.# = numeric_limits<double> = -inf for algorithm easing) while log(spl0) will return -37.534508668464676253705095396408 = log(5e-17)

not necessarily a bug...more like two feature requests :)
09-09-2009 02:27 AM
rob, I don't really understand what your saying ("'Nuff" !? seems I've got a lack of american culture... once again! ;-) but -IF- you're saying that it's not a bug, I disagree. It's indeed due to the floating point and its "-0" capability (i.e. the bug above occurs when spl0 = -0.0, MSB set to 1) but, to be consistent, in such a case, (spl0 == 0) should be false, then ?
no! 0 = -0, floating point or not.

> Forget this post if I misunderstood!

note: other math oddity: normally, log(0) is an invalid opération, just like x/0...

[EDIT] Liteon posted in the meantime!! Thanks for this interesting info. However, I still think it's a bug (wasted a few hours on this stuff) but, since I'm aware of that now, I won't be frustated if it's turned into a FR...

[EDIT2] according to the liteon's post, I should have rather said "(i.e. the bug above occurs when spl0 looks like -0.0...". I really wonder how you know that liteon! It's not said in the JS doc and you can not monitor such accurate values as (5e-17) in the JS "watches"...

... and thanks to mikeroephonics !
09-09-2009 03:04 AM
Human being with feelings
" 'Nuff " is simply short for "enough".

- Mike
09-09-2009 05:48 AM
liteon is a clever guy.

Jeffos, nice work locating the issue, but this will probably get marked "live with it". JS isn't going to get exception handling, and any sort of validation wrapper would require the caller to test the return which is no more convenient than testing the sample for epsilon values before calling log.

Documenting the current behavior is a good FR though :)
09-09-2009 10:04 AM
Yeah, having a == b documented to be "a is within 0.00001 of b" would be good.

Note (for the docs), if you need more accuracy, you could do a*1000000 == b*1000000 etc.

Issue Tools
Subscribe to this issue

All times are GMT -7. The time now is 08:54 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.