Ttelmah Guest
|
Re: arrays? |
Posted: Thu Nov 13, 2003 3:32 am |
|
|
DragonPIC wrote: | I was responding to the original post. I seen nothing of arrays. Just a word and 2 byte variables.
Anyways
Code: | int make_8_from_16(long word, short high_low)
{
#BYTE word0 = word
#BYTE word1 = word + 1
if(high_low == 1)
return(word1);
else
return(word0);
} |
Maybe not the best way to approuch it, but it works. You just have to think about it. |
The danger of replying to the original 'question' (which so often leaves things out), rather than the 'thread'...
If you look at the reply from the original poster, to earlier suggestions, he came back, and turned out to want an array of data that could be initialised automatically as well.
There are dozens of variants on how to do this. Your routine, uses the same basic 'trick', as my union version, and is a pretty good way to do it, and I suspect will normally be treated as 'inline', giving efficient code. :-)
Best Wishes |
|