IsUnsigned() function?

diamond@tkovoa diamond at tkou02.enet.dec.com
Tue Jul 17 17:13:25 AEST 1990


In article <1990Jul16.214155.5087 at Neon.Stanford.EDU> jhsu at Neon.Stanford.EDU (Jeffrey H. Hsu) writes:

>	Here is a C question I was asked at a ________t interview
>	How would you write a space efficient algorithm/function in C that 
>takes in an integer and returns 0 if signed and 1 if unsigned?
>	IsUnsigned(a)
>		int a;
>	{
>	}

Uh, maybe
    /* Remember first to #define signed or #define unsigned. */
    IsUnsigned(a)
    #ifdef signed
            int a;
    #else
            unsigned a;
    #endif
    {
    #ifdef signed
            return 0;
    #else
            return 1;
    #end
    }
Doesn't sound like a job that a programmer would want.....
-- 
Norman Diamond, Nihon DEC     diamond at tkou02.enet.dec.com
This is me speaking.  If you want to hear the company speak, you need DECtalk.



More information about the Comp.lang.c mailing list