static long bitOpsCast(object x)
{
Type xt = x.GetType();
if (xt == typeof(long) || xt == typeof(int) || xt == typeof(short) || xt == typeof(byte) || xt == typeof(ulong) || xt == typeof(uint) || xt == typeof(ushort) || xt == typeof(sbyte))
return RT.longCast(x);
// no bignums, no decimals
throw new ArgumentException("bit operations not supported for: " + xt);
}