(ExecutionContext context, Object o)
| 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) { |