| 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 |