get Total Bits
Calculates the number of bits needed to encode the given segments at the given version. Returns a non-negative number if successful. Otherwise returns -1 if a segment has too many characters to fit its length field, or the total bits exceeds Integer.MAX_VALUE.