Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(893)

Side by Side Diff: src/math.js

Issue 126115: Avoid sign issues with the fast case code for Math.floor(). (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 // ECMA 262 - 15.8.2.8 89 // ECMA 262 - 15.8.2.8
90 function MathExp(x) { 90 function MathExp(x) {
91 if (!IS_NUMBER(x)) x = ToNumber(x); 91 if (!IS_NUMBER(x)) x = ToNumber(x);
92 return %Math_exp(x); 92 return %Math_exp(x);
93 } 93 }
94 94
95 // ECMA 262 - 15.8.2.9 95 // ECMA 262 - 15.8.2.9
96 function MathFloor(x) { 96 function MathFloor(x) {
97 if (!IS_NUMBER(x)) x = ToNumber(x); 97 if (!IS_NUMBER(x)) x = ToNumber(x);
98 if (0 < x && x <= 0xFFFFFFFF) { 98 if (0 < x && x <= 0x7FFFFFFF) {
99 // Numbers in the range [0, 2^32) can be floored by converting 99 // Numbers in the range [0, 2^31) can be floored by converting
100 // them to an unsigned 32-bit value using the shift operator. 100 // them to an unsigned 32-bit value using the shift operator.
101 // We avoid doing so for -0, because the result of Math.floor(-0) 101 // We avoid doing so for -0, because the result of Math.floor(-0)
102 // has to be -0, which wouldn't be the case with the shift. 102 // has to be -0, which wouldn't be the case with the shift.
103 return x << 0; 103 return x << 0;
104 } else { 104 } else {
105 return %Math_floor(x); 105 return %Math_floor(x);
106 } 106 }
107 } 107 }
108 108
109 // ECMA 262 - 15.8.2.10 109 // ECMA 262 - 15.8.2.10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 "tan", MathTan, 233 "tan", MathTan,
234 "atan2", MathAtan2, 234 "atan2", MathAtan2,
235 "pow", MathPow, 235 "pow", MathPow,
236 "max", MathMax, 236 "max", MathMax,
237 "min", MathMin 237 "min", MathMin
238 )); 238 ));
239 }; 239 };
240 240
241 241
242 SetupMath(); 242 SetupMath();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698