草庐IT

long-integer

全部标签

c++ - 带负值的 Unsigned long

请看下面的简单代码:#include#includeusingnamespacestd;intmain(void){unsignedlongcurrentTrafficTypeValueDec;longinput;input=63;currentTrafficTypeValueDec=(unsignedlong)1LL为什么printf()显示负值的currentTrafficTypeValueDec(unsignedlong)?输出是:92233720368547758080-9223372036854775808 最佳答案 %d

c++ - 如何通过 C++ 可执行文件中的 list 启用 "Long Path Aware"行为?

我正在尝试关注Microsoftdocumentation解除Windows10下API中的MAX_PATH文件路径限制。它说:Youcanalsoenablethenewlongpathbehaviorperappviathemanifest:true所以,第一个问题。是否可以在VisualStudio2017的项目属性中启用它?第二个问题:我没有找到上面的答案,所以我决定走手动路线:我创建了additional.manifest文本文件:true然后我将它添加到项目属性中:但是当我编译它时,它给了我这个警告,并且该list在应用程序运行时似乎没有任何效果:1>additional.

c++ - 无法将 'vector<unsigned long>' 转换为 Python 对象

我正在尝试用签名包装一个C++函数vectorOptimized_Eratosthenes_sieve(unsignedlongmax)使用赛通。我有一个包含函数的文件sieve.h,一个静态库sieve.a和我的setup.py如下:fromdistutils.coreimportsetupfromdistutils.extensionimportExtensionfromCython.Distutilsimportbuild_extext_modules=[Extension("sieve",["sieve.pyx"],language='c++',extra_objects=["

c++ - libpng 错误 : PNG unsigned integer out of range

当尝试从内存中读取PNG时,我遇到了这个奇怪的错误:libpngerror::PNGunsignedintegeroutofrange这个错误是由引起的png_read_info(png_ptr,info_ptr);它使用以下处理程序:staticvoidReadDataFromBuffer(png_structppng_ptr,png_bytepoutBytes,png_size_tbyteCountToRead){PNGDataPtrdataptr=(PNGDataPtr)png_get_io_ptr(png_ptr);png_uint_32i;coutlenpdataptr->l

c++ - float、double 和 long double 是否有保证的最小精度?

从我之前的问题“Isfloatingpointprecisionmutableorinvariant?”我收到了一个response其中说,CprovidesDBL_DIG,DBL_DECIMAL_DIG,andtheirfloatandlongdoublecounterparts.DBL_DIGindicatestheminimumrelativedecimalprecision.DBL_DECIMAL_DIGcanbethoughtofasthemaximumrelativedecimalprecision.我查看了这些宏。它们位于标题中。.来自cplusplusreference

c++ - 2 个重载具有相似的转换 - 内置运算符 integer[pointer-to-object]

我有以下类(class):classDictionaryRef{public:operatorbool()const;std::stringconst&operator[](std::stringconst&name)const;//...};然后我尝试使用它:DictionaryRefref=...;ref["asdf"];//error输出提示两个重载,但只列出一个:1>...:errorC2666:'DictionaryRef::operator[]':2overloadshavesimilarconversions1>...:couldbe'conststd::string&D

c++ - 模板参数可以同时是 int 和 unsigned long 吗?

我有以下代码:#includetemplateclassA{};templateclassB;templateclassB>{};intmain(){B>b;return0;}在这里,B被模板化为int而A被模板化为size_t,它是一个unsignedlong我正在使用的两个编译器。当我使用编译器1(当前编译器)时,一切都按照我期望的方式编译和工作。当使用编译器2(我们正在转向的编译器)时,我收到一个编译器错误,指出B没有采用unsignedlong的模板特化-它已解释3作为unsignedlong因为它需要是A的一个,但是对于B。修复很明显,-只需更改B也采用size_t(或更改A

c++ - 预处理器 "invalid integer constant expression"比较 int 和 double

在我的代码中的某处,我有预处理器定义#defineZOOM_FACTOR1我在另一个地方#ifdefZOOM_FACTOR#if(ZOOM_FACTOR==1)#defineFONT_SIZE8#else#defineFONT_SIZE12#endif#else#defineFONT_SIZE8#endif问题是当我将ZOOM_FACTOR值更改为float值时,例如1.5,出现编译错误C1017:无效的整数常量表达式。有谁知道我为什么会收到这个错误,有没有办法在预处理器指令中比较integer和floatingpointnumber? 最佳答案

c++ - make_signed<unsigned long>::type 是 int?

我使用的是VisualStudio2010,下面的代码让我有些困惑:#includeautox=std::make_signed::type();x将是int类型,但我预计会很长。我知道VS10中的int和long都是4字节整数。但是即使一个signedlong装进一个int,int对我来说也不是unsignedlong对应的signedinteger类型。所以我的问题是:这是错误/技术错误还是标准规范允许这种结果? 最佳答案 C++1120.9.7.3[meta.trans.sign]描述了make_signed:IfTnames

C++ signed 和 unsigned int 与 long long 速度

今天,我注意到几个简单的按位和算术运算的速度在int之间有显着差异。,unsigned,longlong和unsignedlonglong在我的64位电脑上。特别是,对于unsigned,以下循环的速度大约是其两倍至于longlong,这是我没想到的。intk=15;intN=30;intmask=(1(完整代码here)以下是计时(以秒为单位)(对于g++-O、-O2和-O3):1.834207723(int)3.054731598(longlong)1.584846237(unsigned)2.201142018(unsignedlonglong)这些时间非常一致(即1%的差值)。