Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:52:43+00:00 2026-06-15T20:52:43+00:00

I want to compare two Byte arrays. byInputBuffer is an array which I filled

  • 0

I want to compare two Byte arrays.
byInputBuffer is an array which I filled by external device. 256 bytes comes in every main loop iteration and is always put in the beginning of byInputBuffer. It is declared like here:

byInputBuffer: array [0..1023] of byte;

DataArray is an array with dynamically declared size. So array is declared like here:

DataArray  : Array of Byte;

and then in code size is declared like here:

 SetLength(DataArray, DataLengthInt);

where DataLengthInt is 130952.

Main loop is iterated from 0 to 511, but when i=0 I get BoolToStr(verify)=-1 in code presented below:

leftBytes := 256;

verify := CompareMem(@byInputBuffer, @DataArray[(i*256)], leftBytes);

But I checked and contents of both arrays when i=0 is equal for the first 256 elements.

My question is why CompareMem returns -1?

Other used declarations:

  leftBytes : Integer;
  verify : Boolean;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:52:45+00:00Added an answer on June 15, 2026 at 8:52 pm

    You are calling CompareMem to compare the first 256 bytes of byInputBuffer against the first 256 bytes of DataArray.

    You are then taking the return value of CompareMem and passing it through BoolToStr. That maps False to '0' and True to '-1'.

    The conclusion therefore is that the first 256 bytes of the two arrays are equal. Because CompareMem returned True.

    Note that your statement in the question that CompareMem returned -1 is obviously incorrect. That is a big part of our confusion. Precision and accuracy are crucial when programming.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to compare two arrays if an email address in array 1 exists
I have a simple application in which I want compare two arrays. function check()
I want to compare two arrays, one coming from a shoppingcart and the other
I have two arrays, @a and @b . I want to do a compare
I want to compare two different types of array list i.e. ArrayList<A> list1 =
I want to compare two multiplication methods implemented in Java which use shift operations
I want to compare two folders on Windows (Vista, XP) which have a large
I want to compare two 1x3 arrays such as: if output[x][y] != [150,25,75] (
I want to compare two arrays, one is set by default and another by
I want to compare two arrays and want to get the number of values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.