int_to_bin

keras_mml.utils.misc.number.int_to_bin(x, pad_len=8)[source]

Converts an integer into its binary representation.

Parameters:
  • x (int) – Integer to convert.

  • pad_len (int, default: 8) – Length to pad to. If the length of the original binary representation is longer than the pad length, this will be ignored.

Returns:

str – Binary representation of the integer.

Examples

>>> int_to_bin(42, pad_len=4)
'101010'
>>> int_to_bin(42, pad_len=8)
'00101010'