(Object x)
| 1274 | } |
| 1275 | |
| 1276 | static public long longCast(Object x){ |
| 1277 | if(x instanceof Integer || x instanceof Long) |
| 1278 | return ((Number) x).longValue(); |
| 1279 | else if (x instanceof BigInt) |
| 1280 | { |
| 1281 | BigInt bi = (BigInt) x; |
| 1282 | if(bi.bipart == null) |
| 1283 | return bi.lpart; |
| 1284 | else |
| 1285 | throw new IllegalArgumentException("Value out of range for long: " + x); |
| 1286 | } |
| 1287 | else if (x instanceof BigInteger) |
| 1288 | { |
| 1289 | BigInteger bi = (BigInteger) x; |
| 1290 | if(bi.bitLength() < 64) |
| 1291 | return bi.longValue(); |
| 1292 | else |
| 1293 | throw new IllegalArgumentException("Value out of range for long: " + x); |
| 1294 | } |
| 1295 | else if (x instanceof Byte || x instanceof Short) |
| 1296 | return ((Number) x).longValue(); |
| 1297 | else if (x instanceof Ratio) |
| 1298 | return longCast(((Ratio)x).bigIntegerValue()); |
| 1299 | else if (x instanceof Character) |
| 1300 | return longCast(((Character) x).charValue()); |
| 1301 | else |
| 1302 | return longCast(((Number)x).doubleValue()); |
| 1303 | } |
| 1304 | |
| 1305 | static public long longCast(byte x){ |
| 1306 | return x; |
no test coverage detected