Page 1 of 1

Adding Byte values inside a ARRAY

Posted: Thu Dec 09, 2021 10:28 am
by dvcam99
Hello together,

may someone can help me.

I would like to sum all byte values inside a string or byte array.

Ok I can do this byte to byte.

Example Byte String/ARRAY: Test_byte[5]

sum_byte_int = Test_byte[0] + Test_byte[1] + Test_byte[2]......and so on!!

But I´m looking for a more elegant way to do it.


BR

Dirk

Re: Adding Byte values inside a ARRAY

Posted: Thu Dec 09, 2021 11:10 am
by stefan.erni
Hi Dirk

What about this way?

And make sure that the sum is not greater than the maximum value of an integer


regards

Stefan

Len_2021-12-09_12-04-37.png
Len_2021-12-09_12-04-37.png (34.73 KiB) Viewed 1341 times

Re: Adding Byte values inside a ARRAY

Posted: Thu Dec 09, 2021 2:07 pm
by dvcam99
Super Stefan!!

Works great!!

Many Thnaks
Dirk