tazntex
- 29th July 2008, 21:07
Hello to all,
What is the best numerical format to use while sending serial data? I am asking because I was using binary, but after reading and rereading some of my program it came to me that my program would not divide binary, assuming this of'course, even my calculator won't do it. I thought about using Hex but if I am using a variable that is a byte, 8 bits right?, and I have three variables total, and I want the first to equal the sum of the second and third then I want to divide by two. Using hex or decimal will it really come out the same?
Ex:
mouse VAR BYTE
cat VAR BYTE
dog VAR BYTE
mouse =%00000001
cat = %00000001
dog =%00000000
dog = (cat + mouse)
IF cat = (dog / 2) then
HIGH 1
Else
LOW 1
ENDIF
What is the best numerical format to use while sending serial data? I am asking because I was using binary, but after reading and rereading some of my program it came to me that my program would not divide binary, assuming this of'course, even my calculator won't do it. I thought about using Hex but if I am using a variable that is a byte, 8 bits right?, and I have three variables total, and I want the first to equal the sum of the second and third then I want to divide by two. Using hex or decimal will it really come out the same?
Ex:
mouse VAR BYTE
cat VAR BYTE
dog VAR BYTE
mouse =%00000001
cat = %00000001
dog =%00000000
dog = (cat + mouse)
IF cat = (dog / 2) then
HIGH 1
Else
LOW 1
ENDIF