I saw this type of unsigned "typeless" that was used a couple of times, but never saw an explanation. I assume that the corresponding type signed exists. Here is an example:
static unsigned long next = 1; int myrand(void) { next = next * 1103515245 + 12345; return(( unsigned )(next/65536) % 32768); } void mysrand( unsigned seed ) { next = seed; }
What I have collected so far:
- on my system, sizeof(unsigned) = 4 (hints at a 32-bit unsigned int)
- it can be used as a shortened version for casting another type into an unsigned version:
signed long int i = -42; printf("%u\n", (unsigned)i);
Is it ANSI C or just a compiler extension?
c types unsigned
hhaamu Jul 23 '09 at 13:44 2009-07-23 13:44
source share