For example
Code: Select all
unsigned int my_value=65535
char sending_buffer[5];
void separate_value(int value)
{
int i=0;
do
{
sending_buffer[i]=value%10;
value=value/10;
i++;
}
while(value >0);
}
void main()
{
separate_value(my_value); // so the sending_buffer[5]=5,3,5,5,6
}
an other alternative with same example;
Code: Select all
unsigned int my_value=65535
char sending_buffer[2];
void separate_value(int value)
{
int eight_bit=0;
eight_bit=value/256; // result is 255 for 65535
sending_buffer[0]=eight_bit; //
sending_buffer[1]=(eight_bit*256)-value; // result is 255 for 65535
}
void main()
{
separate_value(my_value); // so the sending_buffer[2]=255,255
}
different algorithms can be produce .But i want to know which algorithms are commonly used for efficiently fast data sending. What are your opinions about my algorithms , and can you please share algorithms you use . I am waiting for any kind of advice. : )))