什么是无符号的数据类型? [英] what is the unsigned datatype?
本文介绍了什么是无符号的数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看到了这个无符号
无类型类型中使用了几次,但从来没有见过它的解释。我想有一个对应的签署
键入。这里有一个例子:
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;
}
我迄今已收集:
- 我的系统上,的sizeof(无符号)= 4
(在32位无符号整型提示)
- 它可能被用作速记铸造另一类型的无符号版本
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);
这是ANSI C,或者只是一个编译器扩展?
Is this ANSI C, or just a compiler extension?
推荐答案
无符号
真的是 unsigned int类型的简写
,因此,在标准C定义。
unsigned
really is a shorthand for unsigned int
, and so defined in standard C.
这篇关于什么是无符号的数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文