Go Down

Topic: integer save into single bytes (Read 2 times) previous topic - next topic

GekoCH

#15
Mar 23, 2012, 04:59 pm Last Edit: Mar 23, 2012, 05:01 pm by GekoCH Reason: 1

Why do your buffer subscripts start at 1?


Since in the first ([0]) is the adress where the message came from...

is 1 << 0 not the same as pow(256,0).

Or how can I do it differently?

AWOL

1 << 0 is exactly the same value as 2560
The problem lies with the progression
0, 8, 16 ... ?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

GekoCH

so maybe 24 hmmmm :)

But still no success or is it still wrong (24)?


AWOL

I'm posting this from my phone.
I can't see your results, and I'm miles from my Arduinos.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

ea123

Hi,
if you are trying to convert from byte array to long integer, simply use the union in the opposite way:

Code: [Select]

   Number Out;

   Out.barray[0] = b0;
   Out.barray[1] = b1;
   Out.barray[2] = b2;
   Out.barray[3] = b3;

   unsigned long val = Out.num

Go Up