Unsigned considerations

Mike McNally m5 at bobkat.UUCP
Wed Feb 3 04:17:32 AEST 1988


Given a compiler with different sized ``int'' and ``long'', what is the
result of:

    int i;
    unsigned long ul;

    ul = i;

Will the assignment be treated as

    ul = (unsigned long) (unsigned) i;

or as

    ul = (unsigned long) (long) i;

How does the ANSI thing say this conversion should be done?

If you think this is completely obvious and that only a fool would get 
confused, please explain why it's obvious.  It's not at all clear to me 
what should be done (K&R of course doesn't say because ``unsigned long''
doesn't exists there; I don't have any other references).

-- 
Mike McNally, mercifully employed at Digital Lynx ---
    Where Plano Road the Mighty Flood of Forest Lane doth meet,
    And Garland fair, whose perfumed air flows soft about my feet...
uucp: {texsun,killer,infotel}!pollux!bobkat!m5 (214) 238-7474



More information about the Comp.lang.c mailing list