unsigned

Unsigned double in C++?

≡放荡痞女 提交于 2019-12-03 05:23:38
问题 Why doesn't C++ support unsigned double syntax? 回答1: Because typical floating point formats don't support unsigned numbers. See, for instance, this list of IEEE 754 formats. Adding a numerical format that isn't supported by common hardware just makes life difficult for compiler writers, and is probably not considered worth the effort. 回答2: C++ doesn't support unsigned floating point types because most floating point hardware doesn't support unsigned floating point types. Some graphics cards

Get the signed/unsigned variant of an integer template parameter without explicit traits

杀马特。学长 韩版系。学妹 提交于 2019-12-03 04:55:15
I am looking to define a template class whose template parameter will always be an integer type. The class will contain two members, one of type T , and the other as the unsigned variant of type T -- i.e. if T == int , then T_Unsigned == unsigned int . My first instinct was to do this: template <typename T> class Range { typedef unsigned T T_Unsigned; // does not compile public: Range(T min, T_Unsigned range); private: T m_min; T_Unsigned m_range; }; But it doesn't work. I then thought about using partial template specialization, like so: template <typename T> struct UnsignedType {}; //

Unsigned integer bit field shift yields signed integer

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Let consider the following program test.c : #include <stdio.h> struct test { unsigned int a : 5 ; }; int main () { unsigned int i ; struct test t = { 1 }; for ( i = 0 ; i < t . a << 1 ; i ++) printf ( "%u\n" , i ); return 0 ; } When compiled with gcc -Wsign-compare test.c the following warning is produced (tested with gcc 4.8.1): test . c : 9 : 19 : warning : comparison between signed and unsigned integer expressions [- Wsign - compare ] for ( i = 0 ; i < t . a << 1 ; i ++) ^ clang -Wsign-compare test.c produces the following

Linker errors in Android NDK (undefined reference to `__cxa_end_cleanup&#039;)

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm getting this output after adding in a set of code from a colleague: ./obj/local/armeabi/objs/jniWrapper/native.o: In function `_Vector_base': D:/opt/android-ndk/sources/cxx-stl/stlport/stlport/stl/_vector.h:73: undefined reference to `__cxa_end_cleanup' ./obj/local/armeabi/objs/jniWrapper/native.o:(.ARM.extab.text._ZNSt6vectorIhSaIhEEC1ERKS1_[std::vector<unsigned char, std::allocator<unsigned char> >::vector(std::vector<unsigned char, std::allocator<unsigned char> > const&)]+0x0): undefined reference to `__gxx_personality_v0' ./obj/local

MySQL cannot create foreign key constraint

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm having some problems creating a foreign key to an existing table in a mysql database. I have the table exp : +-------------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------------+------+-----+---------+-------+ | EID | varchar(45) | NO | PRI | NULL | | | Comment | text | YES | | NULL | | | Initials | varchar(255) | NO | | NULL | | | ExpDate | date | NO | | NULL | | | InsertDate | date | NO | | NULL | | | inserted_by | int(11) unsigned | YES | MUL | NULL | | +--

Error when use custom DQL function with Doctrine and Symfony2

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I use Symfony 2 and the ORM Doctrine. I want to create and register a custom DQL function. In fact, I want to use the SQL function " CAST " in my request, like this : $qb = $this -> _em -> createQueryBuilder (); $qb -> select ( 'd' ) -> from ( '\Test\MyBundle\Entity\MyEntity' , 'd' ) -> orderBy ( 'CAST(d.myField AS UNSIGNED)' , 'ASC' ) return $qb -> getQuery ()-> getResult (); For this, I have created a "CastFunction" who extend "FunctionNode" : namespace Test \MyBundle\DQL ; use Doctrine \ORM\Query\AST\Functions\FunctionNode ; use

Convert 0x1234 to 0x11223344

匿名 (未验证) 提交于 2019-12-03 02:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I expand the hexadecimal number 0x1234 to 0x11223344 in a high-performance way? unsigned int c = 0x1234, b; b = (c & 0xff) << 4 | c & 0xf | (c & 0xff0) << 8 | (c & 0xff00) << 12 | (c & 0xf000) << 16; printf("%p -> %p\n", c, b); Output: 0x1234 -> 0x11223344 I need this for color conversion. Users provide their data in the form 0xARGB, and I need to convert it to 0xAARRGGBB . And yes, there could be millions, because each could be a pixel. 1000x1000 pixels equals to one million. The actual case is even more complicated, because a single

Linking Cuda in C++ issue

匿名 (未验证) 提交于 2019-12-03 02:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've searched existing questions, but I can't seem to solve this. I have a blur_mask.cc file with: #include <iostream> #include <ctime> #include <opencv2/highgui/highgui.hpp> #include <opencv2/gpu/gpu.hpp> #include <vector_types.h> #include <cuda.h> #include <cuda_runtime.h> extern "C" void gpuBlurMask(unsigned char* srcData, int srcStep, uchar3* dst, int dstStep, int width, int height, float *mask, int maskStep, int maskWidth, int maskHeight, int blockSize=16); using namespace std; using namespace cv; using namespace cv::gpu; void blurMask

Inline Assembly Jump Error

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Why does this fail, once Masm reaches jmp? struct gdt_entry { unsigned short limit_low; unsigned short base_low; unsigned char base_middle; unsigned char access; unsigned char granularity; unsigned char base_high; }; struct gdt_ptr { unsigned short limit; unsigned int base; }; struct gdt_entry gdt[3]; struct gdt_ptr gp; void gdt_flush() { __asm{ lgdt [gp] mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ; push the address on the stack push 0x08 mov eax, offset flush2 push eax ; ret use the previous pushed address _emit

Android - Download App

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm attempting to create an unsigned internal test build of an application I'm writing, and I'm getting some strange errors. I'm using Eclipse's Android Tools to generate an Unsigned APK, then attach it to our group wiki, at which point a user can click to download it, and attempt to install it, but it keeps erroring with: Application not installed LogCat reveals: 06 - 06 11 : 11 : 25.532 : W / ActivityManager ( 1401 ): No content provider found for permission revoke : file : ///mnt/sdcard/Download/2012-06-06-02-App-Name.apk 06 -