[Freeciv-Dev] Re: PATCH: load_map_data macro (PR#1012)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Raimar Falke wrote:
>
> On Tue, Oct 16, 2001 at 11:20:44PM -0400, Jason Dorje Short wrote:
> > Raimar Falke wrote:
> > +/***************************************************************
> > +This returns an ascii hex value of the given half-byte of the
> > +binary integer. See ascii_hex2bin().
> > + example: bin2ascii_hex(0xa00, 2) == 'a'
> > +***************************************************************/
> > +#define bin2ascii_hex(value, halfbyte_wanted) \
> > + ('a' - 10 + (char)(((value) >> ((halfbyte_wanted) * 4)) & 0xf))
> ('a' - 10 + (char)(x))
>
> 0<=x<=15
>
> For: x=0 ('a'-10+0) == 'W' WRONG
> For: x=11 ('a'-10+11) = ('a'+1) == 'b' OK
>
> IMHO there is no correct way without evaluating "value" more than one
> or creating a local variable. So I would vote for the hex_chars
> approach.
I just wanted to see if you were paying attention :-).
Anyway, I agree. Let's forget this new patch, and move back to the
previous one.
jason
|
|