I've seen this unsigned
"typeless" type used a couple of times, but never seen an explanation for it. I suppose there's a corresponding signed
type. Here's an example:
static unsigned long next = 1;
/* RAND_MAX assumed to be 32767 */
int myrand(void) {
next = next * 1103515245 + 12345;
return((unsigned)(next/65536) % 32768);
}
void mysrand(unsigned seed) {
next = seed;
}
What I have gathered so far:
- on my system, sizeof(unsigned) = 4
(hints at a 32-bit unsigned int)
- it might be used as a shorthand for casting another type to the unsigned version:
signed long int i = -42;
printf("%u\n", (unsigned)i);
Is this ANSI C, or just a compiler extension?