uint64

Converting (u)int64_t to NSNumbers

喜你入骨 提交于 2019-12-05 02:13:37
So essentially my question is this, I am creating an NSMutableDictionary using uint64_t objects as the key. Is there any better way to create them than doing this? uint64_t bob=7; NSNumber *bobsNumber; #if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 bobsNumber=[NSNumber numberWithUnsignedLong:bob]; #else bobsNumber=[NSNumber numberWithUnsignedLongLong:bob]; #endif This would work as long as you didn't include it in a binary file/sockets/NSData object/whatever. But is there any better way of doing this? I really would like to be sure that the

std::atoll with VC++

别说谁变了你拦得住时间么 提交于 2019-12-05 01:36:22
I have been using std::atoll from cstdlib to convert a string to an int64_t with gcc. That function does not seem to be available on the Windows toolchain (using Visual Studio Express 2010). What is the best alternative? I am also interested in converting strings to uint64_t . Integer definitions taken from cstdint . MSVC have _atoi64 and similar functions, see here For unsigned 64 bit types, see _strtoui64 use stringstreams ( <sstream> ) std::string numStr = "12344444423223"; std::istringstream iss(numStr); long long num; iss>>num; use boost lexical_cast ( boost/lexical_cast.hpp ) std::string

SQL bigint hash to match c# int64 hash [duplicate]

依然范特西╮ 提交于 2019-12-01 16:55:19
This question already has an answer here: SQL Server varbinary bigint with BitConverter.ToInt64 values are different 1 answer I am trying to create a universal hashing alogrithim that hashes a string as a 64 bit int. I am able to hash the strings correctly: sql: select convert ( varchar(64), HASHBYTES ( 'SHA1', 'google.com' ), 2 ) returns BAEA954B95731C68AE6E45BD1E252EB4560CDC45 C# System.Security.Cryptography.SHA1 c = System.Security.Cryptography.SHA1.Create(); System.Text.StringBuilder sb = new StringBuilder(); byte[] b = c.ComputeHash(Encoding.UTF8.GetBytes("google.com")); for (int i = 0; i

Go: convert uint64 to int64 without loss of information

白昼怎懂夜的黑 提交于 2019-12-01 05:12:25
The problem with the following code: var x uint64 = 18446744073709551615 var y int64 = int64(x) is that y is -1 . Without loss of information, is the only way to convert between these two number types to use an encoder and decoder? buff bytes.Buffer Encoder(buff).encode(x) Decoder(buff).decode(y) Note, I am not attempting a straight numeric conversion in your typical case. I am more concerned with maintaining the statistical properties of a random number generator. VonC Seeing -1 would be consistent with a process running as 32bits. See for instance the Go1.1 release notes (which introduced

How to define an unsigned 64-bit integer in Delphi7?

纵饮孤独 提交于 2019-11-30 09:12:48
In Delphi 7, int64s are signed, if I try to declare a hex constant larger than $8000000000000000 (eg, what is really an uint64) I get an error. Can you advise some workarounds, please? You can make a variant record like so type muint64 = record case boolean of true: (i64 : int64); false:(lo32, hi32: cardinal); end; Now you can just use the cardinals to fill your uint64 with unsigned data. The other option would be to use code like this: const almostmaxint64 = $800000045000000; var muint64: int64; begin muint64:= almostmaxint64; muint64:= muint64 shl 1; end Without support from the compiler you

How to define an unsigned 64-bit integer in Delphi7?

喜欢而已 提交于 2019-11-29 12:50:16
问题 In Delphi 7, int64s are signed, if I try to declare a hex constant larger than $8000000000000000 (eg, what is really an uint64) I get an error. Can you advise some workarounds, please? 回答1: You can make a variant record like so type muint64 = record case boolean of true: (i64 : int64); false:(lo32, hi32: cardinal); end; Now you can just use the cardinals to fill your uint64 with unsigned data. The other option would be to use code like this: const almostmaxint64 = $800000045000000; var

Swift converts C's uint64_t different than it uses its own UInt64 type

不打扰是莪最后的温柔 提交于 2019-11-29 11:54:44
I am in the process of porting an application from (Objective-)C to Swift but have to use a third-party framework written in C. There are a couple of incompatibilities like typedefs that are interpreted as Int but have to be passed to the framework's functions as UInts or the like. So to avoid constant casting operations throughout the entire Swift application I decided to transfer the C header files to Swift, having all types as I I need them to be in one place. I was able to transfer nearly everything and have overcome a lot of hurdles, but this one: The C header defines a struct which

Is Shifting more than 32 bits of a uint64_t integer on an x86 machine Undefined Behavior?

梦想的初衷 提交于 2019-11-29 06:05:55
Learning the hard way, I tried to left shift a long long and uint64_t to more than 32 bits on an x86 machine resulted 0 . I vaguely remember to have read somewhere than on a 32 bit machine shift operators only work on the first 32 bits but cannot recollect the source. I would like to know is if Shifting more than 32 bits of a uint64_t integer on an x86 machine is an Undefined Behavior? Daniel Fischer The standard says (6.5.7 in n1570): 3 The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. If the value of the right operand

difference between stdint.h and inttypes.h

牧云@^-^@ 提交于 2019-11-28 15:51:58
What is the difference between stdint.h and inttypes.h? If none of them is used, uint64_t is not recognized but with either of them it is a defined type. See the wikipedia article for inttypes.h. Use stdint.h for a minimal set of definitions; use inttypes.h if you also need portable support for these in printf, scanf, et al. stdint.h Including this file is the "minimum requirement" if you want to work with the specified-width integer types of C99 (i.e. "int32_t", "uint16_t" etc.). If you include this file, you will get the definitions of these types , so that you will be able to use these

How do you deal with numbers larger than UInt64 (C#)

允我心安 提交于 2019-11-27 22:08:00
In C#, how can one store and calculate with numbers that significantly exceed UInt64's max value (18,446,744,073,709,551,615)? By using a BigInteger class; there's one in the the J# libraries (definitely accessible from C#), another in F# (need to test this one), and there are freestanding implementations such as this one in pure C#. Can you use the .NET 4.0 beta? If so, you can use BigInteger . Otherwise, if you're sticking within 28 digits, you can use decimal - but be aware that obviously that's going to perform decimal arithmetic, so you may need to round at various places to compensate.