[Icc-avr] Casting
Johannes Assenbaum
jassenbaum at htp-tel.de
Mon Jan 14 11:41:12 PST 2008
As someone mentioned before, this is only safe for Little Endian, but as AVRs are Little Endian, there will be no problem with iccavr.
Btw: Shortest code (no optimisation enabled) will be with source value casted.
Data[7] = ((unsigned int)(Channel_One) >> 8);
Data[8] = ((unsigned int)(Channel_One));
Best regards,
Johannes
>> Andrew wrote:
>>> Hi,
>>>
>>> When casting and int to two char' (a MSB and LSB) is it safe to do the
>>> following:-
>>> Data[7] = (Channel_One >> 8);
>>> Data[8] = (Channel_One);
>>>
> I always use the above solution, it should be perfectly legal and it has
> never failed me on any compiler. I think it is quite clear for any
> programmer of embedded systems what this does.
> regards
> Johan
> _______________________________________________
> Icc-avr mailing list
> Icc-avr at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-avr
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.2/1223 - Release Date: 13.01.08 20:23
More information about the Icc-avr
mailing list