草庐IT

UINT_MIN

全部标签

c++ - boost::date_time (boost-145) 使用带有微秒计算的 64 位 uint,没有截断

我正在使用date_time来抽象掉平台特性。我需要生成一个64位微秒分辨率uint64_t,它将用于序列化。我不明白下面出了什么问题。#include#include#includeusingnamespaceboost::posix_time;usingboost::uint64_t;ptimeUNIX_EPOCH(boost::gregorian::date(1970,1,1));intmain(){ptimecurrent_time=microsec_clock::universal_time();std::cout这是我得到的输出。originaltime:2010-Dec-

c++ - 所以,我们有 int32_t、int16_t、uint64_t 等。但是 atoi32、atoi16、atoui64 等在哪里……?

我想将表示数字的字符串输入转换为相应的数字类型。问题是我有严格的类型要求,例如,我不能接受x>=2^15其中int16_t预期值(有符号)。如果不从头编写所有转换函数,我该如何处理这种情况?附言请不要建议boost::lexical_cast-我已经在使用它了。我正在谈论的功能将取代lexical_cast的默认实现通过特定模板特化的模板,即:templateinlineint32_tlexical_cast(constchar*const&arg){}templateinlineint16_tlexical_cast(constchar*const&arg){}...理想情况下,最好

c++ - 无法解析类型 'uint32_t'

我正在Eclipse(3.8.1)CDT中开发C++程序。我在Debian8上使用gcc编译器。我还使用了一个用C++编写的名为opendnp3的开源库,它需要uint32_t来解析,因为它是多个方法调用和构造函数中的参数。在opendnp对象中,intellisense没有列出__uint32_t然而,确实解决了。类型在中定义(解决得很好)。我可以打开声明并清楚地看到'using::uint32_t;'在那里。在我的搜索中,我添加了-std=c++11到“C/C++构建-->设置->工具设置->GCCC++编译器”下的“所有选项”,我还重建了项目索引并重新启动了Eclipse,但它仍

c++ - 为什么不允许使用 `std::uniform_int_distribution<uint8_t>` 和 `std::uniform_int_distribution<int8_t>`?

作为documentationsays:Theeffectisundefinedifthisisnotoneofshort,int,long,longlong,unsignedshort,unsignedint,unsignedlong,orunsignedlonglong.如果我不关心范围,我可以屏蔽掉较大类型的位来生成随机数。如果不是,那就更复杂了。为什么不默认提供字节类型? 最佳答案 关于此uniform_int_distributionshouldbepermitted有一个图书馆工作组Unresolved[1]问题它说,除

c++ - reinterpret_cast unsigned char* as uint64_t* - 这是 UB 吗?

假设我们采用一个非常大的unsignedchar数组。std::arrayblob;//...fillarray...(注意:它已经对齐了,问题不在于对齐。)然后我们将其作为uint64_t[]并尝试访问它:constautoptr=reinterpret_cast(blob.data());std::cout转换为uint64_t然后从中读取对我来说看起来很可疑。但是UBsan,-Wstrict-aliasing并没有触发它。Google在FlatBuffers中使用了这种技术.此外,Cap'n'Proto使用此too.这是未定义的行为吗? 最佳答案

ios - 在 Objective C UIFontDescriptor.h 常量中使用枚举、uint32_t 和位移位

我正在学习Objective-C,并且对枚举类型有一些了解。这是我正在关注的教程中使用的一段示例代码:UIFont*bodyFont=[UIFontpreferredFontForTextStyle:UIFontTextStyleBody];UIFontDescriptor*existingDescriptor=[bodyFontfontDescriptor];UIFontDescriptorSymbolicTraitstraits=existingDescriptor.symbolicTraits;traits|=UIFontDescriptorTraitBold;UIFontDes

android - htc desire hd 无法拾取(-webkit-min-device-pixel-ratio : 2) media query?

我一直在做一些移动网络应用程序测试,并注意到htcdesirehd屏幕图像似乎都很模糊,向我表明此屏幕的像素比为2,与iphone4相同。我已将我的(-webkit-min-device-pixel-ratio:2)媒体查询中的所有更新的x2图像,以至少为iphone4克服这个问题,但令我惊讶的是,这种愿望也没有解决这个问题?我在这里缺少什么吗?@mediaonlyscreenand(-webkit-min-device-pixel-ratio:2),onlyscreenand(min-device-pixel-ratio:2){/*SocialIcons*/#social-icons

ios 将字符串 "5 hours 10 min"转换为整数小时和分钟

我正在尝试从字符串"5小时10分钟"中获取整数变量中的小时数和分钟数。谁能给我解决方案。NSString*duration=@"5hours10min";inthours=5intmin=10 最佳答案 请尝试使用以下代码来检索int值。@try{NSString*myString=@"5hours10min";NSArray*myWords=[myStringcomponentsSeparatedByCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:

ios - 将 uint8_t 转换为 NSData

我已经根据AppleDeveloper网站上提供的示例在iOS应用程序中实现了publickeyprivatekeyRSA加密。如果我加密并返回uint8_tcipherBuffer,然后从uint8_tcipherBuffer解密,它会完美运行。但是,我需要将加密数据作为NSData存储到.xcdata模型中。我遇到的问题是将uint8_tcipherBuffer可靠地转换为NSData和/或将NSData转换回uint8_t什么时候解密。解密的数据似乎被截断了。这就是我将uint8_t加密缓冲区转换为NSData的方式:return[NSDatadataWithBytesNoCop

ios - NSString 到 UInt64

如何将NSString转换为UInt64?例如,如果存在UInt64Value辅助方法,则如下所示:NSString*value=@"1234567";UInt64convertedValue=[valueUInt64Value];我正尝试在iOS项目中执行此操作。 最佳答案 为完整性提出另一种可能性:NSScanner*scanner=[NSScannerscannerWithString:value];unsignedlonglongconvertedValue=0;[scannerscanUnsignedLongLong:&c