MCPcopy Index your code
hub / github.com/clojure/clojure / longCast

Method longCast

src/jvm/clojure/lang/RT.java:1276–1303  ·  view source on GitHub ↗
(Object x)

Source from the content-addressed store, hash-verified

1274}
1275
1276static 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
1305static public long longCast(byte x){
1306 return x;

Callers 15

coerceAdapterReturnMethod · 0.95
invokeLMethod · 0.95
invokeLLMethod · 0.95
invokeDLMethod · 0.95
invokeOLMethod · 0.95
invokeLLLMethod · 0.95
invokeLOLMethod · 0.95
invokeOLLMethod · 0.95
invokeDDLMethod · 0.95
invokeLDLMethod · 0.95
invokeDLLMethod · 0.95
invokeOOLMethod · 0.95

Calls 4

bitLengthMethod · 0.80
bigIntegerValueMethod · 0.80
longValueMethod · 0.45
doubleValueMethod · 0.45

Tested by

no test coverage detected