import struct


def set_dint_(bytearray_: bytearray, byte_index: int, dint: int):
    """Set value in bytearray to dint
    Notes:
        Datatype `dint` consists in 4 bytes in the PLC.
        Maximum possible value is 2147483647.
        Lower posible value is -2147483648.
    Args:
        bytearray_: buffer to write.
        byte_index: byte index from where to start writing.
    Examples:
        >>> data = bytearray(4)
        >>> snap7.util.set_dint(data, 0, 2147483647)
        >>> data
            bytearray(b'\\x7f\\xff\\xff\\xff')
    """
    dint = int(dint)
    _bytes = struct.unpack('4B', struct.pack('>i', dint))
    for i, b in enumerate(_bytes):
        bytearray_[byte_index + i] = b

    return bytearray_