[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] typecast

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] typecast
Date: Tue, 25 Mar 2003 17:28:40 +0100 (MET)

Torsten Hahn <address@hidden> wrote:

> number8 = (uint8_t)(number16);
> do i get the highest 8 bit from number16 into number8 ?

You get the low-order 8 bits.

> Or is there a better (safer) way to geht the most significant byte
> of an 16, 32 ...  Bit value ?

number8 = (uint8_t)(number16 >> 8);

You can also use a union, but then you'll depend on the endianess of
the underlying machine.

J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]