unsigned

呼吸灯和花样流水灯 51单片机实现

Deadly 提交于 2019-11-30 16:57:41
1.用C51单片机实现花样流水灯,代码如下: #include <reg52.h> #define LED_All P1            //led灯所用的接口,单片机接口不同,led灯不同 void delayms() { unsigned char x = 0;           unsigned char i; unsigned char y = 0; while(y < 0.001)             //定义led灯的切换的延时时间,越小越快 {                    //i,x,y均可以修改 x = 0; while(x<100) { i = 0; while(i<100) { i++; } x++; } y++; } } #define LED_NUM 8          //定义led灯的数量,可快速实现不同用途的修改 void main() { unsigned char k; unsigned char j; unsigned char LED_ALL[] = {0XFE,0XFD,0XFB,0XF7,0XEF,0XDF,0XBF,0X7F};      //led灯亮灭的十六进制数组 unsigned char LED_ALL1[] = {0XFC,0XF3,0XCF,0X3F};   while(1)   {     for

would doing arithmetic operation on a pair of signed and unsigned numbers be legal?

给你一囗甜甜゛ 提交于 2019-11-30 15:33:19
I'm more than half way through learning assembly and I'm familiar with the concept of how signed and unsigned integers are presented in bits, I know that it might seem a weird question of which the answer would be pretty obvious, but I'm wondering if using an arithmetic operation like addition makes sense for a pair of numbers that one of them is considered signed and the other one unsigned, I've thought of multiple examples like below that will yield a correct result: 10000001 (1-byte integer and considered unsigned, equivalent to 129) + 11111111 (1-byte integer and considered signed(two's

2019/9/27 题解:【T100043】 2019/9/27 Day2 T1 无穷序列

岁酱吖の 提交于 2019-11-30 15:12:02
    题解:【T100043】 无穷序列   题目:      输入输出格式:     样例:      数据范围:      思路:                                          k==6时的数列   此数列构造方式是第k轮构造在第k-1轮的基础上,将数列复制并添加到原数列后,再添加上数字k。                                 示意图(比例出了一点问题但不要在意)   由此我们不难发现: 原数列第k轮复制后某一待求数a[x]与原数列a[i]对应并且相等,即 x=i+(last[k-1] - 0)(原数列长度) 且 a[i]=a[x] 。 只有在第k轮构造时,数字k才会第一次出现。即当 x=last[ k ](第k轮最后一个数位置) 时有a[x]= k 。   综上可通过将待求数a[x]向前逆推得到a[i],当a[i]为第一次出现时有a[x]=a[i]=last[k]=k。    代码: 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #define mod 998244353//记得模 5 using namespace std; 6 unsigned long long last[65]; 7 unsigned long long

Understanding Java unsigned numbers

﹥>﹥吖頭↗ 提交于 2019-11-30 14:40:14
I want to understand how to convert signed number into unsigned. lets say I have this: byte number = 127; // '1111111' In order to make it unsigned I have to choose "bigger" data type 'short' and apply AND operator with value 0x00ff. short number2; number2 = number & 0x00ff; Why does it make the number unsigned? Java doesn't actually have unsigned primitives. The value 127 is actually represented by '01111111' the first bit being the sign (0 is positive). An unsigned byte would be able to hold values 0 to 255, but 127 is the maximum for a signed byte. Since a byte has 8 bits, and the signed

攻防世界--The_Maya_Society

萝らか妹 提交于 2019-11-30 13:33:20
测试文件: https://adworld.xctf.org.cn/media/task/attachments/17574fc423474b93a0e6e6a6e583e003.zip 我们直接将Linux当前日期设置为2012-12-21,运行文件就能得到flag,不过还是要分析一下。 1.准备 获取信息 64位文件 2.IDA打开 主函数main signed __int64 __fastcall main(__int64 a1, char **a2, char **a3) { size_t v3; // rbx size_t v4; // rax unsigned __int64 v6; // rax unsigned __int64 v7; // rax unsigned __int64 v8; // rsi char *v9; // rdi time_t timer; // [rsp+18h] [rbp-128h] char v11[8]; // [rsp+20h] [rbp-120h] char src; // [rsp+40h] [rbp-100h] char s; // [rsp+60h] [rbp-E0h] unsigned __int64 v14; // [rsp+C8h] [rbp-78h] char v15; // [rsp+D4h] [rbp-6Ch]

How to cast or convert an unsigned int to int in C?

℡╲_俬逩灬. 提交于 2019-11-30 11:38:04
My apologies if the question seems weird. I'm debugging my code and this seems to be the problem, but I'm not sure. Thanks! It depends on what you want the behaviour to be. An int cannot hold many of the values that an unsigned int can. You can cast as usual: int signedInt = (int) myUnsigned; but this will cause problems if the unsigned value is past the max int can hold. This means half of the possible unsigned values will result in erroneous behaviour unless you specifically watch out for it. You should probably reexamine how you store values in the first place if you're having to convert

Java和mysql的数据类型对应

左心房为你撑大大i 提交于 2019-11-30 09:23:08
java mysql 数据类型对照 类型名称 显示长度 数据库类型 JAVA类型 JDBC类型索引(int) 描述 VARCHAR L+N VARCHAR java.lang.String 12 CHAR N CHAR java.lang.String 1 BLOB L+N BLOB java.lang.byte[] -4 TEXT 65535 VARCHAR java.lang.String -1 INTEGER 4 INTEGER UNSIGNED java.lang.Long 4 TINYINT 3 TINYINT UNSIGNED java.lang.Integer -6 SMALLINT 5 SMALLINT UNSIGNED java.lang.Integer 5 MEDIUMINT 8 MEDIUMINT UNSIGNED java.lang.Integer 4 BIT 1 BIT java.lang.Boolean -7 BIGINT 20 BIGINT UNSIGNED java.math.BigInteger -5 FLOAT 4+8 FLOAT java.lang.Float 7 DOUBLE 22 DOUBLE java.lang.Double 8 DECIMAL 11 DECIMAL java.math.BigDecimal 3 BOOLEAN 1

java mysql 数据类型对照

主宰稳场 提交于 2019-11-30 09:22:51
java mysql 数据类型对照 类型名称 显示长度 数据库类型 JAVA类型 JDBC类型索引(int) 描述 VARCHAR L+N VARCHAR java.lang.String 12 CHAR N CHAR java.lang.String 1 BLOB L+N BLOB java.lang.byte[] -4 TEXT 65535 VARCHAR java.lang.String -1 INTEGER 4 INTEGER UNSIGNED java.lang.Long 4 TINYINT 3 TINYINT UNSIGNED java.lang.Integer -6 SMALLINT 5 SMALLINT UNSIGNED java.lang.Integer 5 MEDIUMINT 8 MEDIUMINT UNSIGNED java.lang.Integer 4 BIT 1 BIT java.lang.Boolean -7 BIGINT 20 BIGINT UNSIGNED java.math.BigInteger -5 FLOAT 4+8 FLOAT java.lang.Float 7 DOUBLE 22 DOUBLE java.lang.Double 8 DECIMAL 11 DECIMAL java.math.BigDecimal 3 BOOLEAN 1

C : Modulus operator on unsigned int gives unexpected output

旧城冷巷雨未停 提交于 2019-11-30 09:12:03
问题 #include <stdio.h> main() { unsigned a = -20; unsigned b = 10; printf("%d\n", (a % b)); printf("%d\n", (-20 % 10)); } Output: 6 0 The second printf prints the expected value of 0 while the first printf prints 6. Why this unexpected output with unsigned ints? 回答1: unsigned int can hold values from 0 to UINT_MAX , no negative values. So -20 is converted to -20 + UINT_MAX + 1 . On your system: (-20 + UINT_MAX + 1) % 10 != -20 % 10 回答2: And what are you expecting? a % b is equivalent to, let's

Why do MIPS operations on unsigned numbers give signed results?

我的未来我决定 提交于 2019-11-30 08:49:50
When I try working on unsigned integers in MIPS, the result of every operation I do remains signed (that is, the integers are all in 2's complement), even though every operation I perform is an unsigned one: addu , multu and so fourth... When I print numbers in the range [2^31, 2^32 - 1] I get their 'overflowed' negative value as if they were signed (I guess they are). Though, when I try something like this: li $v0, 1 li $a0, 2147483648 # or any bigger number syscall the printed number is always 2147483647 (2^31 - 1) I'm confused... What am I missing? PS : I haven't included my code as it isn