前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >unsigned int在c语言中是什么意思_尿液报告里面vc什么意思

unsigned int在c语言中是什么意思_尿液报告里面vc什么意思

作者头像
全栈程序员站长
发布2022-09-21 10:41:23
8790
发布2022-09-21 10:41:23
举报

大家好,又见面了,我是你们的朋友全栈君。

在一个项目中,要求用VC6写DLL,其中有字段要求用UINT 16,vc6中没有UINT16。

UINT16,无符号int要16位,占2字节(1字节byte=8位bit),1111 1111 1111 1111,表示范围0~65535。

在此,我想到用别的类型代替它,并对范围测试

下面用vc6随便建一个程序,添加一个button双击添加代码:

0000 0000 0000 0000 ~ 1111 1111 1111 1111

short:默认带符号的,最高位1为符号位,表示范围 : -32768~32767

unsigned short:为不带符号的,表示范围: 0~65535

signed short :为带符号的,表示范围: -32768~32767

__int16,

__int32,这俩不知道是啥,不研究了,只是在vc6中无意看到有这种类型,等以后有空再研究。

代码语言:javascript
复制
<span style="white-space:pre">	</span>short a=1;
	unsigned short b=1;
	signed short c=1;
	__int16 d;
	__int32 e;

	CString strSho;
	int i;
	while(1)
	{
	if (a>0)
	{
		a++;
	}
	else
	{
		a= a-1;
		//strSho.Format("a = %d",a);
		//AfxMessageBox(strSho);
		break;
	}
	}

	while(1)
	{
		if (b>0)
		{
			b++;
		}
		else
		{
			b = b - 1;
			break;
		}
	}

	while(1)
	{
		if (c>0)
		{
			c++;
		}
		else
		{
			c = c - 1;
			break;
		}
	}

	while(1)
	{
		if (d>0)
		{
			d++;
		}
		else
		{
			d = d - 1;
			break;
		}
	}

	while(1)
	{
		if (e > 0)
		{
			e++;
		}
		else
		{
			e = e - 1;
			break;
		}
	}

	strSho.Format("MAX a = %d,MAX b = %d, MAX c = %d, MAX d = %d, MAX e = %d",a,b,c,d,e);
	AfxMessageBox(strSho);

结果:

a=32767;

b=65535;

c=32767;

d=-13109;//这个不认识,算了,扔了吧

e=-858983461;//这个也不认识

补充:

刚刚看了下,__int16,__int32的介绍,下面是msdn的说法:

https://msdn.microsoft.com/en-us/library/29dh1w7z.aspx

Microsoft C/C++ features support for sized integer types. You can declare 8-, 16-, 32-, or 64-bit integer variables by using the __intn type specifier, where n is 8, 16, 32, or 64.

The following example declares one variable for each of these types of sized integers:

Copy __int8 nSmall; // Declares 8-bit integer __int16 nMedium; // Declares 16-bit integer __int32 nLarge; // Declares 32-bit integer __int64 nHuge; // Declares 64-bit integer The types __int8, __int16, and __int32 are synonyms for the ANSI types that have the same size, and are useful for writing portable code that behaves identically across multiple platforms. The __int8 data type is synonymous with type char, __int16 is synonymous with type short, and __int32 is synonymous with type int. The __int64 type has no ANSI equivalent.

Example The following sample shows that an __intxx parameter will be promoted to int:

Copy // sized_int_types.cpp

#include <stdio.h>

void func(int i) { printf_s(“%s\n”, __FUNCTION__); }

int main() { __int8 i8 = 100; func(i8); // no void func(__int8 i8) function // __int8 will be promoted to int } func

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/170549.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档