[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] typecast
From: |
Sander Pool |
Subject: |
Re: [avr-gcc-list] typecast |
Date: |
Tue, 25 Mar 2003 15:30:08 -0800 |
I appologize for being the n'th person with the identical reply. Well, I
added a small rant about gcc :-)
Next time I'll read my entire inbox before replying. I was so exited I knew
the answer to a question I just -had- to send it :-)
Sander
----- Original Message -----
From: "Sander Pool" <address@hidden>
To: "Torsten Hahn" <address@hidden>; <address@hidden>
Sent: Tuesday, March 25, 2003 3:21 PM
Subject: Re: [avr-gcc-list] typecast
>
> I've been bitten by type conversions quite a bit in the last few weeks, it
> seems you really really have to spell it out to gcc to make it do the
right
> thing. But that's not what you were asking :-)
>
> If you want to have the MSBs of a 16 bit number and stick them in an 8 bit
> variable you could do:
>
> number8 = (uint8_t) (number16 >> 8);
>
> This -should- discard the 8 MSBs of the right shifted number, leaving you
> the original 8 MSBs from number16.
>
> Sander
>
- [avr-gcc-list] typecast, Torsten Hahn, 2003/03/25
- Re: [avr-gcc-list] typecast, Markus Assfalg, 2003/03/25
- Re: [avr-gcc-list] typecast, E. Weddington, 2003/03/25
- Re: [avr-gcc-list] typecast, Joerg Wunsch, 2003/03/25
- Re: [avr-gcc-list] typecast, Larry Barello, 2003/03/25
- Re: [avr-gcc-list] typecast, Sander Pool, 2003/03/25
- Re: [avr-gcc-list] typecast,
Sander Pool <=