Bit vector to number conversions for compact database storage