How convert integer to low and high byte?

Hello!How convert integer to low and high byte?Example int temp=20 convert low byte=0 and high byte=2....

Look at http://arduino.cc/en/Reference/Modulo for the units variable, and just divide by 10 for the 10s variable.

int temp = 23;
int high = temp / 10;
int low = temp % 10;

Example int temp=20 convert low byte=0 and high byte=2....

Sadly, that isn't how decimal numbers are stored.

If you really want to do what the title implies: http://arduino.cc/en/Reference/LowByte http://arduino.cc/en/Reference/HighByte

Have you had a look at itoa()?

@AWOL - I thought about mentioning that, but just took the easy route.

@bubulindo - Why convert to a string?

If its a 16bit integer, then:

unsigned char ucHigh = (unsigned char)((intValue >> 0x08) & 0xff); unsigned char ucLow = (unsigned char)(intValue & 0xff);

unsigned char ucHigh = (unsigned char)((intValue >> 0x08) & 0xff);

Isn't the "& 0xff" redundant?

Probably, however it won't do any harm. I use this when coding in Java as without it the result becomes signed.