Unsigned considerations
Henry Spencer
henry at utzoo.uucp
Sun Feb 7 15:02:50 AEST 1988
> int i;
> unsigned long ul;
>
> ul = i;
>
> How does the ANSI thing say this conversion should be done?
X3J11 (November draft) says ul = (unsigned long)(long)i; is how it happens.
This makes a certain amount of sense: adjusting the size before adjusting
the signedness produces results that I would say are (a) less surprising,
and (b) more portable across variations in relative sizes of data types.
--
Those who do not understand Unix are | Henry Spencer @ U of Toronto Zoology
condemned to reinvent it, poorly. | {allegra,ihnp4,decvax,utai}!utzoo!henry
More information about the Comp.lang.c
mailing list