MCPcopy Create free account
hub / github.com/mozilla/rhino / clz32

Method clz32

rhino/src/main/java/org/mozilla/javascript/NativeMath.java:192–229  ·  view source on GitHub ↗
(
            Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args)

Source from the content-addressed store, hash-verified

190 }
191
192 private static Object clz32(
193 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {
194 double x = ScriptRuntime.toNumber(args, 0);
195 if (x == 0 || Double.isNaN(x) || Double.isInfinite(x)) {
196 return Double32;
197 }
198 long n = ScriptRuntime.toUint32(x);
199 if (n == 0) {
200 return Double32;
201 }
202
203 int place = 0;
204 if ((n & 0xFFFF0000) != 0) {
205 place += 16;
206 n >>>= 16;
207 }
208 if ((n & 0xFF00) != 0) {
209 place += 8;
210 n >>>= 8;
211 }
212 if ((n & 0xF0) != 0) {
213 place += 4;
214 n >>>= 4;
215 }
216 if ((n & 0b1100) != 0) {
217 place += 2;
218 n >>>= 2;
219 }
220 if ((n & 0b10) != 0) {
221 place += 1;
222 n >>>= 1;
223 }
224 if ((n & 0b1) != 0) {
225 place += 1;
226 }
227
228 return Double.valueOf(32 - place);
229 }
230
231 private static Object cos(
232 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {

Callers 1

math-clz32.jsFile · 0.80

Calls 4

toNumberMethod · 0.95
toUint32Method · 0.95
isNaNMethod · 0.45
valueOfMethod · 0.45

Tested by

no test coverage detected