# Thread: multiplying to bye arrays

1. ## multiplying to bye arrays

Hi all,
I am trying to write a C code to multiply 2 byte arrays and then divide the answer by 200 . any ideas how to do that ?
thank you

2. That depends entirely what you mean by "multiplying two byte arrays". Multiplying one byte by one byte? Multiplying two-bytes-at-a-time by two-bytes-at-a-time? What about overflow?

In any event, some sort of loop seems indicated.

3. thank you very much ... the two arrays are the same , i just need to square one and then divide the answer by 200

4. Originally Posted by john27
thank you very much ... the two arrays are the same , i just need to square one and then divide the answer by 200
So then that's what you do. Go through every element of the array, multiply the element by itself and divide by 200.

5. You should probably cast to int before multiplying. Otherwise you risk overflow even when your result is less than the max value of a byte.

6. Are the array's elements independent of each other?

Yes => Do what @tabstop told you.

No => Forget it! Use an arbitrary-sized arithmetics library instead.