Fix a bug that Math.round() retunrs incorrect results for huge integers
Created attachment 47901 [details] Patch
Comment on attachment 47901 [details] Patch How about this instead? - if (signbit(arg) && arg >= -0.5) - return jsNumber(exec, -0.0); - return jsNumber(exec, floor(arg + 0.5)); + double integer = ceil(arg); + return jsNumber(exec, integer - (integer - arg > 0.5));
Comment on attachment 47901 [details] Patch Patch seems fine. But you should consider my patch with ceil that avoids the need for the separate if statement. You could use ? : instead of the way I did it. Or use my code exactly as is (as long as it passes your tests).
Would be nice to have tests cases for the maximum and minimum double values as well to make sure they don't turn into infinity when rounded.
Thank you for the quick review. Ok, I followed the proposed code, and add test cases for minimum/maximum values. Landed as r54197 and r54198.