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

Method toInt32

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

Source from the content-addressed store, hash-verified

355 }
356
357 public static Long toInt32(ExecutionContext context, Object o) {
358 Number number = toNumber(context, o);
359 if (Double.isInfinite(number.doubleValue()) || Double.isNaN(number.doubleValue())) {
360 return 0L;
361 }
362
363 double doubleNum = number.doubleValue();
364
365 long posInt = (long) ((sign(doubleNum)) * Math.floor(Math.abs(doubleNum)));
366
367 long int32bit = modulo(posInt, 4294967296L);
368
369 if (int32bit >= 2147483648L) {
370 int32bit = int32bit - 4294967296L;
371 }
372 return int32bit;
373 }
374
375 public static boolean isCallable(Object o) {
376 return (o instanceof JSCallable);

Callers 6

interpretMethod · 0.95
interpretMethod · 0.95
lengthMethod · 0.95
callMethod · 0.95
callMethod · 0.95
visitMethod · 0.95

Calls 4

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

Tested by

no test coverage detected