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

Method toUint16

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

Source from the content-addressed store, hash-verified

307 }
308
309 public static Long toUint16(ExecutionContext context, Object o) {
310 // 9.7
311 Number n = toNumber(context, o);
312
313 if (n instanceof Double) {
314 if (((Double) n).isInfinite() || ((Double) n).isNaN()) {
315 return 0L;
316 }
317 }
318
319 long posInt = (long) (sign(n) * Math.floor(Math.abs(n.longValue())));
320
321 return modulo(posInt, 65536);
322 }
323
324 protected static int sign(Number n) {
325 if (n.doubleValue() < 0) {

Callers 1

callMethod · 0.95

Calls 4

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

Tested by

no test coverage detected