public static int BitLength(BigInteger x) { if (x.IsZero()) { return 0; } return x.Abs().GetBitCount(); }