unsigned

DHL11温湿度模块代码

左心房为你撑大大i 提交于 2019-12-25 12:51:49
1 //****************************************************************// 2 // DHT21使用范例 3 //单片机 : AT89S52 或 STC89C52RC 4 // 功能 :串口发送温湿度数据 波特率 9600 5 //硬件连接: P2.0口为通讯口连接DHT11,DHT11的电源和地连接单片机的电源和地,单片机串口加MAX232连接电脑 6 // 公司 :奥松电子 7 //****************************************************************// 8 9 #include <reg51.h> 10 #include <intrins.h> 11 // 12 typedef unsigned char U8; /* defined for unsigned 8-bits integer variable 无符号8位整型变量 */ 13 typedef signed char S8; /* defined for signed 8-bits integer variable 有符号8位整型变量 */ 14 typedef unsigned int U16; /* defined for unsigned 16-bits integer

c++ 随机函数用法

风流意气都作罢 提交于 2019-12-25 07:30:07
C++中rand()函数可以用来产生随机数,但是是属于伪随机数。 rand()函数用法:   在使用rand()函数的时候,首先需要包含头文件#include<stdlib.h>,用法是int rand(void),产生的随机数范围是0~65536,类型为unsigned int,不能超过范围。rand()函数不接受参数,默认以1为种子(即起始值)。 随机数生成器总是以相同的种子开始,所以形成的伪随机数列也相同,失去了随机意义。若要不同,此时需要使用函数srand()进行初始化。   srand()函数用来初始化随机数发生器,用法为void srand(unsigned int seed),参数seed必须是个整数,如果每次seed都设相同值,rand()所产生的随机数值每次就会一样。   可以利用srand((unsigned int)(time(NULL))的方法,产生不同的随机数种子,因为每一次运行程序的时间是不同的。   产生随机数的用法 1) 给srand()提供一个种子,它是一个unsigned int类型; 2) 调用rand(),它会根据提供给srand()的种子值返回一个随机数(在0到RAND_MAX之间); 3) 根据需要多次调用rand(),从而不间断地得到新的随机数; 4) 无论什么时候,都可以给srand()提供一个新的种子,从而进一步“随机化”rand(

mysql字段类型范围说明:int、bigint、smallint、tinyint,char、varchar、nvarchar

人走茶凉 提交于 2019-12-24 19:18:55
MySQL的列类型主要有三种:数字、字串和日期。 mysql官方说明文档: http://dev.mysql.com/doc/refman/5.1/zh/data-types.html 下面来详细的说明,不一定准确不一定完整,请多包含或者提出您的建议,我很乐意倾听,呵呵. 数字列类型 int、bigint、smallint、tinyint   数字列类型用于储存各种数字数据,如价格、年龄或者数量。数字列类型主要分为两种:整数型和浮点型。所有的数字列类型都允许有两个选 项:UNSIGNED和ZEROFILL。选择UNSIGNED的列不允许有负数,选择了ZEROFILL的列会为数值添加零。下面是MySQL中可用的 数字列类型 • TINYINT——一个微小的整数,支持 -128到127(SIGNED),0到255(UNSIGNED),需要1个字节存储 • BIT——同TINYINT(1) • BOOL——同TINYINT(1) • SMALLINT——一个小整数,支持 -32768到32767(SIGNED),0到65535(UNSIGNED),需要2个字节存储 MEDIUMINT——一个中等整数,支持 -8388608到8388607(SIGNED),0到16777215(UNSIGNED),需要3个字节存储 • INT——一个整数,支持 -2147493648到2147493647

What are the equivalents of Swifts integer “Overflow Operators” &*, &+ and &- in Java?

大憨熊 提交于 2019-12-24 08:49:26
问题 Swift offers so called "Overflow Operators" &*, *+, &- for integer arithmetics (Swift Advanced Operators). They are designed to truncate the number of available bits when performing an operation that would lead to an overflow. For example: var unsignedOverflow = UInt8.max // --> 255 unsignedOverflow = unsignedOverflow &+ 1 // --> 0, instead of overflow Since Java doesn't support unsigned integers, there is probably not a real equivalent. In Java 8, there are functions like Integer

portable signed/unsigned byte cast,C++

时光怂恿深爱的人放手 提交于 2019-12-24 07:43:23
问题 I am using signed to unsigned byte(int8_t) cast to pack byts. uint32_t(uint8_t(byte)) << n This works using GCC on Intel Linux. Is that portable for other platforms/compilers, for example PowerPC? is there a better way to do it? using bitset is not possible in my case. I am using stdint via boost 回答1: If you are using boost/cstdint.hpp from the Boost Integer library, then yes, the typedefs are portable (cross-platform.) The boost/cstdint.hpp header is meant to implement C99 stdint.h

“#if 0/#if 1 ... #endif”的作用

蓝咒 提交于 2019-12-24 07:01:15
今看到一帖子,讨论“#if 0/#if 1 ... #endif”的作用,感觉不错,故拿来分享。 原帖地址:http://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=2028608&bbs_page_no=1005&bbs_id=9999 1、先说“#if 0/#if 1 ... #endif”的作用,楼上诸位或多或少都说到了一点,但都没有说到关键的地方。我们知道,C标准不提供C++里的“//”这样的单行风格注释而只提供“/* */”这样的块注释功能,我们通常使用它写代码中说明性的注释文字(注释作用)以及在调试时关闭某段代码对编译器的可见性(屏蔽作用),当然,这里所谓的“注释作用”和“屏蔽作用”是我们从功能上下的主观定义,对预处理器而言,两者并无任何区别。对于前者,因为“注释”中不会再出现“注释”和“需要屏蔽的代码段”,所以不会有嵌套的需求,所以通常不会有问题;而对于后者,当我们在调试程序时需要“屏蔽”某段代码时,该段代码中可能包含着前述的“注释”和/或“已被屏蔽的代码段”,这时就产生了“/* */”嵌套使用的需求,但SB的C标准恰恰不允许我们这么干。当你试图使用嵌套的块注释功能时,会发现预处理器把最外层注释的开始和最内层注释的结尾这两者之间的内容处理成了注释,而其后一直到最外层注释结尾的内容被当作了“有效代码”—

Uboot启动流程分析(二)

纵然是瞬间 提交于 2019-12-24 06:58:52
1、前言 在前面的文章Uboot启动流程分析(一)中,链接如下: https://www.cnblogs.com/Cqlismy/p/12000889.html 已经简单地分析了low_level_init函数,其调用流程如下: save_boot_params_ret | cpu_init_crit |   | |   lowlevel_init |   | |   s_init | _main 接下来,则继续往下分析_main函数。 2、_main函数 在save_boot_params_ret的最后,会运行bl _main这句代码,Uboot则将会跳转到_main函数中去运行,该函数的定义在arch/arm/lib/crt0.S文件中,_main函数的功能已经在文件中注释得很清楚了,先来看看_main函数实现的功能是什么,注释如下: /* * This file handles the target-independent stages of the U-Boot * start-up where a C runtime environment is needed. Its entry point * is _main and is branched into from the target's start.S file. * * _main execution

[转]ffmpeg在vs2008中的使用

只愿长相守 提交于 2019-12-23 18:54:13
最终采用了 https://blog.csdn.net/smilestone_322/article/details/7605101 的方案 转自: http://blog.sina.com.cn/s/blog_62949ff40101egbw.html 1.到 http://ffmpeg.zeranoe.com/builds/ 下载ffmpeg-20131120-git-e502783-win32-dev和ffmpeg-20131120-git-e502783-win32-shared 2.打开vs2008建立控制台程序,将ffmpeg-20131120-git-e502783-win32-dev下的include和lib拷贝到程序目录下,设置和头文件和库的依赖目录 3.编译过程: 错误一:无法打开包括文件:“inttypes.h”: No such file or directory 解决方法:删除之,并在其之前添加如下代码: #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) # define CONFIG_WIN32 #endif #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined

Why doesn't returning 0x80000000 from a function that returns int32_t cause a warning?

末鹿安然 提交于 2019-12-23 13:30:27
问题 Consider: int32_t f() { return 0x80000000; } Why doesn't that cause a compiler warning (at least on GCC)? 0x80000000 is out of the range of int32_t ( INT32_MAX is 0x7fffffff ). I believe this should cause an implicit cast - is that correct? Further consder: if (f() == 0x80000000) foo(); The above causes no warning on GCC. However int32 ret = f(); if (ret == 0x80000000) baz(); Causes "warning: comparison between signed and unsigned integer expressions". I believe this is because 0x80000000 has

Is it safe to assign -1 to an unsigned int to get the max value?

好久不见. 提交于 2019-12-23 11:55:47
问题 Is it safe to assign -1 to an unsigned int, or other unsigned c++ data type, if I need to get the max value? Is there any situation where it won't give me the highest value an unsigned data type can contain? 回答1: To be on a safe side, use std::numeric_limits<unsigned int>::max() . Casting -1 to unsigned would work on mainstream platforms, but it is not guaranteed by the standard AFAIR. UPD: I'll correct myself. (unsigned)-1 is required to be UINT_MAX in C, see the answer here 回答2: I think you