MCPcopy Create free account
hub / github.com/dynjs/dynjs / toUint32

Method toUint32

src/main/java/org/dynjs/runtime/Types.java:332–349  ·  view source on GitHub ↗
(ExecutionContext context, Object o)

Source from the content-addressed store, hash-verified

330 }
331
332 public static Long toUint32(ExecutionContext context, Object o) {
333 // 9.5
334 Number n = toNumber(context, o);
335
336 if (n instanceof Double) {
337 if (((Double) n).isInfinite() || ((Double) n).isNaN() || ((Double) n).doubleValue() == -0) {
338 return (long) 0;
339 }
340 }
341
342 double d = n.doubleValue();
343
344 long posInt = (long) ((sign(d)) * Math.floor(Math.abs(d)));
345
346 long int32bit = modulo(posInt, 4294967296L);
347
348 return (long) int32bit;
349 }
350
351 public static long modulo(long a, long b) {
352 // because Java modulo doesn't deal with negatives the way the

Callers 15

interpretMethod · 0.95
defineOwnPropertyMethod · 0.95
isArrayIndexMethod · 0.95
isSparseMethod · 0.95
getMethod · 0.95
putMethod · 0.95
callMethod · 0.95
callMethod · 0.95
callMethod · 0.95
callMethod · 0.95
callMethod · 0.95
callMethod · 0.95

Calls 4

toNumberMethod · 0.95
signMethod · 0.95
moduloMethod · 0.95
isNaNMethod · 0.45

Tested by

no test coverage detected