unsigned

PHP 扩展与 ZEND 引擎的整合

心不动则不痛 提交于 2019-11-29 16:29:44
PHP 扩展是对 PHP 功能的一个补充,编写完 PHP 扩展以后, ZEND 引擎需要获取到 PHP 扩展的信息,比如 phpinfo() 函数是如何列出 PHP 扩展的信息,PHP 扩展中的函数如何提供给 PHP 程序员使用,这些是开发 PHP 扩展需要了解的内容。 这些内容并不复杂,在开发 PHP 扩展时只要愿意去了解一下相关的部分就可以了,在这里,我给出一个简单的介绍。 PHP 扩展中负责提供信息的结构体为 zend_module_entry,该结构体的定义如下: 1 struct _zend_module_entry { 2 unsigned short size; 3 unsigned int zend_api; 4 unsigned char zend_debug; 5 unsigned char zts; 6 const struct _zend_ini_entry *ini_entry; 7 const struct _zend_module_dep *deps; 8 const char *name; 9 const struct _zend_function_entry *functions; 10 int (*module_startup_func)(INIT_FUNC_ARGS); 11 int (*module_shutdown_func)

Why is imul used for multiplying unsigned numbers?

为君一笑 提交于 2019-11-29 14:39:55
问题 I compiled the following program: #include <stdint.h> uint64_t usquare(uint32_t x) { return (uint64_t)x * (uint64_t)x; } This disassembles to: 0: 89 f8 mov eax,edi 2: 48 0f af c0 imul rax,rax 6: c3 ret But imul is the instruction for multiplying signed numbers. Why is it used by gcc then? /edit: when using uint64_t the assembly is similar: 0: 48 0f af ff imul rdi,rdi 4: 48 89 f8 mov rax,rdi 7: c3 ret 回答1: TL:DR: because it's a faster way of getting the correct result when we don't care about

ZYNQ随笔——AXI_GPIO裸机设计

给你一囗甜甜゛ 提交于 2019-11-29 14:36:56
1. 硬件平台搭建 在Block Design里添加ZYNQ7 Processing System和AXI_GPIO模块,双击AXI_GPIO设置为输出,驱动外部IO器件(如LED)。搭建好的系统结构如下图所示: 2. 软件SDK设计 SDK软件设计可以参考官方设计文档,主要API函数有, int XGpio_Initialize(XGpio * InstancePtr,u16 DeviceId) void XGpio_SetDataDirection(XGpio * InstancePtr,unsigned Channel,u32 DirectionMask) void XGpio_DiscreteWrite(XGpio * InstancePtr,unsigned Channel,u32 Data) u32 XGpio_DiscreteRead(XGpio * InstancePtr,unsigned Channel) void XGpio_DiscreteClear(XGpio * InstancePtr,unsigned Channel,u32 Mask) 具体代码如下, int main(void) { int Status; volatile int Delay; /* Initialize the GPIO driver */ Status = XGpio

MurmurHash PK CityHash

人盡茶涼 提交于 2019-11-29 13:48:28
1. 概述 murmurhash是 Austin Appleby于2008年创立的一种 非加密hash算法 ,适用于基于hash进行查找的场景。murmurhash最新版本是MurMurHash3,支持 32位、64位及128位值 的产生。 murmurhash标准使用c++实现,但是也有其他主流语言的支持版本,包括:perl、c#、ruby、python、java等。murmurhash在多个开源项目中得到应用,包括libstdc、libmemcached 、nginx、hadoop等。 CityHash是Google发布的字符串散列算法,和murmurhash一样,属于非加密型hash算法。CityHash算法的开发是受到了 MurmurHash的启发。其主要优点是大部分步骤包含了至少两步独立的数学运算。现代 CPU 通常能从这种代码获得最佳性能。 CityHash 也有其缺点:代码较同类流行算法复杂。 Google 希望为速度而不是为了简单而优化,因此没有照顾较短输入的特例 。 Google 号称CityHash64 在速度方面至少能提高 30%(这个,肯定不是和murmurhash比咯),并有望提高多达两倍。此外,这些算法的统计特性也很完备。 目前CityHash支持 64、128、256 位 2.使用: 1)Murmurhash直接添加源码: //------------

Why int plus uint returns uint?

会有一股神秘感。 提交于 2019-11-29 13:47:07
int plus unsigned int returns an unsigned int. Should it be so? Consider this code: #include <boost/static_assert.hpp> #include <boost/typeof/typeof.hpp> #include <boost/type_traits/is_same.hpp> class test { static const int si = 0; static const unsigned int ui = 0; typedef BOOST_TYPEOF(si + ui) type; BOOST_STATIC_ASSERT( ( boost::is_same<type, int>::value ) ); // fails }; int main() { return 0; } If by "should it be" you mean "does my compiler behave according to the standard": yes . C++2003: Clause 5, paragraph 9: Many binary operators that expect operands of arithmetic or enumeration type

Unsigned Double

落爺英雄遲暮 提交于 2019-11-29 13:07:20
I need to use an unsigned double but it turns out C# does not provide such a type. Does anyone know why? Floating point numbers are simply the implementation of the IEEE 754 spec. There is no such thing as an unsigned double there as far as i know. http://en.wikipedia.org/wiki/IEEE_754-2008 Why do you need an unsigned floating point number? As pointed out by Anders Forsgren, there is no unsigned doubles in the IEEE spec (and therefore not in C#). You can always get the positive value by calling Math.Abs() and you could wrap a double in a struct and enforce the constraint there: public struct

How does in assembly does assigning negative number to an unsigned int work?

三世轮回 提交于 2019-11-29 13:06:42
I Learned About 2's Complement and unsigned and signed int. So I Decided to test my knowledge , as far as i know that a negative number is stored in 2's complement way so that addition and subtraction would not have different algorithm and circuitry would be simple. Now If I Write int main() { int a = -1 ; unsigned int b = - 1 ; printf("%d %u \n %d %u" , a ,a , b, b); } Output Comes To Be -1 4294967295 -1 4294967295 . Now , i looked at the bit pattern and various things and then i realized that -1 in 2's complement is 11111111 11111111 11111111 11111111 , so when i interpret it using %d , it

How to declare 8-bit unsigned integer in ruby?

陌路散爱 提交于 2019-11-29 12:13:48
In c++ you can do: uint8 foo_bar How would we do the same thing in ruby? Any alternatives? This post seems close to it maybe someone can explain? Ruby abstracts away the internal storage of integers, so you don't have to worry about it. If you assign an integer to a variable, Ruby will deal with the internals, allocating memory when needed. Smaller integers are of type Fixnum (stored in a single word), larger integers are of type Bignum . a = 64 a.class #=> Fixnum; stored in a single word a += 1234567890 a.class #=> Bignum; stored in more than a single word Ruby is dynamically typed, so you

mysql常用数据类型的使用方式--数值型

点点圈 提交于 2019-11-29 12:13:16
1) BIGINT [( display_size )] [AUTO_INCREMENT] [UNSIGNED] [ZEROFILL] 存储大小: 8 字节 描述:最大整数类型( -9223372036854775808 到 9223372036854775807 ,无符号为 0 到 18446744073709551615 )。 2) BIT [( bits )] 存储大小: bits 位数 +7 或 8 位 描述:存储指定位数的位图值。 3) DEC 与 DECIMAL 同义。 4) DECIMAL [( precision , [ scale ])] [UNSIGNED] [ZEROFILL] 存储大小:不确定 描述:存储精度重要的浮点数,如货币值等。需要指定精度和刻度(小数点后位数), MySQL 的默认精度为 10 ,默认刻度为 0 。 5) DOUBLE [( display_size , digits )] [ZEROFILL] 存储大小: 8 字节 描述:双精度浮点数(负数范围 -1.7976931348623157E+308 到 -2.2250738585072014E-308 , 0 ,正数范围 2.2250738585072014E-308 到 1.7976931348623157E+308 )。 6) DOUBLE PRECISION 与 DOUBLE 同义

Testing for a maximum unsigned value

旧街凉风 提交于 2019-11-29 11:21:30
Is this the correct way to test for a maximum unsigned value in C and C++ code: if(foo == -1) { // at max possible value } where foo is an unsigned int , an unsigned short , and so on. For C++, I believe you should preferably use the numeric_limits template from the <limits> header : if (foo == std::numeric_limits<unsigned int>::max()) /* ... */ For C, others have already pointed out the <limits.h> header and UINT_MAX . Apparently, "solutions which are allowed to name the type are easy", so you can have : template<class T> inline bool is_max_value(const T t) { return t == std::numeric_limits<T