Clib Compare Memory Method

The Clib Compare Memory method compares the contents of two buffers. It returns one of the following values:

  • If the value in the buf1 argument is less than the value in the buf2 argument, then it returns a negative number.

  • If the value in the buf1 argument is greater than the value in the buf2 argument, then it returns a positive number.

  • If the value in the buf1 argument is the same as the value in the buf2 argument, then it returns 0.

Format

Clib.memcmp(buf1, buf2[, length])

The following table describes the arguments for the Clib Compare Memory method.

Argument Description

buf1

A variable that contains the name of a buffer.

buf2

A variable that contains the name of a buffer.

length

The number of bytes that this method compares. It does one of the following depending on how you specify the length argument:

  • You specify the length argument. It compares the buffers from the first byte up to the length that you specify. For example, if you specify 1024 as the length, then it compares the first 1024 bytes of the buffer.

  • You do not specify the length argument. It compares the full length of the buffers.

If one buffer is shorter than the other buffer, then it compares the buffers from the beginning byte up to the length of the shorter buffer.