avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] typecast


From: Markus Assfalg
Subject: Re: [avr-gcc-list] typecast
Date: Tue, 25 Mar 2003 17:27:19 +0100

Hi,
>
> if i have
>
> uint16_t number16 = 1234;
> uint8_t number8;
>
> number8 = (uint8_t)(number16);
>
> do i get the highest 8 bit from number16 into number8 ? 

In the example, you get the LSB !

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

You can use the following code to determine the MSB:

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

Greeting

Markus

> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list

-- 
dSys e.K.
Soeflinger Str. 100
D-89077 Ulm
Tel: +49.731.933-1170
Fax: +49.731.933-1179
web: www.dsys.de


reply via email to

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