int64

I want to get the low 32 bit of a int64 as int32

非 Y 不嫁゛ 提交于 2019-11-30 02:44:45
问题 I have an Int64 value, but I only need the lower 32 bits. Thus I want a quick way to get the Int32 value from the lower 32 bits of the Int64 value. Thanks 回答1: Do something like this: long tempLong = ((yourLong >> 32) << 32); //shift it right then left 32 bits, which zeroes the lower half of the long int yourInt = (int)(yourLong - tempLong); This may not be the most compact way to do it, but it seems to be the most readable to me. The following code will extract the high half of the long:

FILETIME to __int64

浪尽此生 提交于 2019-11-30 01:53:16
问题 What is the proper way to convert a FILETIME structure into __int64 ? Can you please tell me? 回答1: I don't think you're suppose to: "Do not cast a pointer to a FILETIME structure to either a ULARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows." Source. If you really wanted it would be something like: __int64 to_int64(FILETIME ft) { return static_cast<__int64>(ft.dwHighDateTime) << 32 | ft.dwLowDateTime; } FILETIME ft = // ... __int64 t = to_int64(ft); But

Best way to load a 64-bit integer to a double precision SSE2 register?

大兔子大兔子 提交于 2019-11-29 17:19:32
问题 What is the best/fastest way to load a 64-bit integer value in an xmm SSE2 register in 32-bit mode? In 64-bit mode, cvtsi2sd can be used, but in 32-bit mode, it supports only 32-bit integers. So far I haven't found much beyond: use fild , fstp to stack then movsd to xmm register load the high 32-bit portion, multiply by 2^32, add the low 32-bit First solution is slow, second solution might introduce precision loss ( edit: and it is slow anyway, since the low 32 bit have to be converted as

How to convert string to int64_t?

跟風遠走 提交于 2019-11-29 12:00:20
问题 How to convert program parameter from argv to int64_t ? atoi() is suitable only for 32 bit integers. 回答1: A C99 conforming attempt. [edit] employed @R. correction // Note: Typical values of SCNd64 include "lld" and "ld". #include <inttypes.h> #include <stdio.h> int64_t S64(const char *s) { int64_t i; char c ; int scanned = sscanf(s, "%" SCNd64 "%c", &i, &c); if (scanned == 1) return i; if (scanned > 1) { // TBD about extra data found return i; } // TBD failed to scan; return 0; } int main(int

How to convert an int64 to int in Go?

陌路散爱 提交于 2019-11-29 11:31:32
问题 In Go, what is the best strategy for converting int64 to int ? I am having difficulty comparing the two package main import ( "math" "strings" "strconv" ) type largestPrimeFactor struct { N int Result int } func main() { base := largestPrimeFactor{N:13195} max := math.Sqrt(float64(base.N)) maxStr := strconv.FormatFloat(max, 'E', 'G', 64) maxShift := strings.Split(maxStr, ".")[0] maxInt, err := strconv.ParseInt(maxShift, 10, 64) if (err != nil) { panic(err) } on this next line for a := 2; a <

Under C# is Int64 use on a 32 bit processor dangerous

微笑、不失礼 提交于 2019-11-29 11:29:08
问题 I read in the MS documentation that assigning a 64-bit value on a 32-bit Intel computer is not an atomic operation; that is, the operation is not thread safe. This means that if two people simultaneously assign a value to a static Int64 field, the final value of the field cannot be predicted. Three part question: Is this really true? Is this something I would worry about in the real world? If my application is multi-threaded do I really need to surround all my Int64 assignments with locking

Should I use long long or int64_t for portable code?

走远了吗. 提交于 2019-11-28 22:24:27
I have an open-source codebase that is written in both C and C++. I'm looking for an integer type that is guaranteed to be at least 64 bits wide, which can be reliably compiled on most OS X (Intel, 64-bit) and Linux boxes with open-source C and C++ compilers, without too much extra work on the end user's part. Windows and 32-bit client support are not important at this time. I did some testing on OS X, and the latest GCC that ships with the developer tools does not support C+11 mode (and therefore does not seem to guarantee availability of long long ). Clang does not support this, either,

Swift - Cast Int64 to AnyObject for NSMutableArray

不羁的心 提交于 2019-11-28 12:27:35
Hi I have a NSMutableArray and I try this: var ma = NSMutableArray() let number:Int64 = 8345834344 ma.addObject(number)// Error "Type Int64 does not conform to protocol AnyObject" How to add Int64 variable to NSMutableArray() ? You are using a Foundation array (NSMutableArray), so you should use a Foundation number object: ma.addObject(NSNumber(longLong:number)) You could also use a native swift array: var ma = [Int64]() ma.append(number) Like so much of Swift, this is implemented in Swift. So you can do this (or the equivalent for the types you want) which will magically make it possible to

Isn't an Int64 equal to a long in C#?

纵然是瞬间 提交于 2019-11-28 11:53:04
I have been playing around with SQL and databases in C# via SqlCeConnection . I have been using ExecuteReader to read results and BigInt values for record IDs which are read into Longs. Today I have been playing with SQL statements that use COUNT based statements ('SELECT COUNT(*) FROM X') and have been using ExecuteScalar to read these single valued results. However, I ran into an issue. I can't seem to store the values into a Long data type, which I have been using up to now. I can store them into Int64's. I have been using BigInt for record IDs to get the maximum potential number of records

Which initializer is appropriate for an int64_t?

爱⌒轻易说出口 提交于 2019-11-28 09:55:59
I like to initialize my variables to some "dummy" value and have started to use int64_t and uint64_t . So far, it looks like there are at least three ways I could initialize an int64_t to a particular value (and with slight changes for the unsigned equivalent): int64_t method_one = 0; int64_t method_two = 0LL; int64_t method_three = INT64_C(0); I use GCC and target OS X and Linux. I'd like to pick a method that aims for ease of portability and clarity — but correctness, above all. Am I overthinking this, or is there a "best" or "most recommended" approach for initializing this variable type,