Quantcast
Channel: Compare 2 byte arrays - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Compare 2 byte arrays

$
0
0

I have 2 int arrays.

int[] data1 #int[] data2 #

I want to create a 3rd int[] data3 which is the differences between the 2 other arrays.

Let us take the 1st value in data1.

The value is 15 (e.g.).

Now let us take the 1st value in data2.

The value is 3 (e.g.).

The 1st value in data3 would be 12.

BUT, if the 1st values were the other way round i.e.

data1[0]  = 3data2[0]  = 15

then the difference would be -12. Yet I want it to be just 12.

at the moment I have a for loop and I do the computation stuff there to get that type of result.

  1. Is there a way to do data1-data2 = data3 without enumerating througha loop?
  2. If so, can I just get the differences without using minus numbers?

Thanks

N.B.In response to the 'closers'. I agree with you to a certain point. What I need to add to this questions is this:

I am looking for the most efficient (quickest way but low memory being 2nd priority) to facilitate this. Using Linq (as I understand it) can be the slowest approach?


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images