Questions tagged [uint64]

The uint64 is a datatype that represents an unsigned integer and is coded on 64 bits in memory.

uint64 is a datatype that represents an and is coded on 64 bits in memory. Unlike its counterpart which is , uint64 can only be used to store positive integers, of values between 0 and 264 - 1.

192 questions
9
votes
3 answers

Are there uint64 literals in Go?

I'm looking at the numeric types in Go. I want to use uint64 literals. Is this possible in Go? Here's an example of how I'd like to use uint64 literals: for i := 2; i <= k; i += 1 { // I want i to be a uint64 ... }
user3835277
9
votes
3 answers

Convert uint64 to int64 without loss of information

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…
wheaties
  • 35,646
  • 15
  • 94
  • 131
9
votes
3 answers

Why does an uint64_t needs more memory than 2 uint32_t's when used in a class? And how to prevent this?

I have made the following code as an example. #include struct class1 { uint8_t a; uint8_t b; uint16_t c; uint32_t d; uint32_t e; uint32_t f; uint32_t g; }; struct class2 { …
Pinna_be
  • 4,517
  • 2
  • 18
  • 34
9
votes
1 answer

SQL bigint hash to match c# int64 hash

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', …
Eulalie367
  • 198
  • 4
  • 17
7
votes
1 answer

Unexpected result after converting uint64_t to double

In the following code: #include ... uint64_t t1 = 1510763846; uint64_t t2 = 1510763847; double d1 = (double)t1; double d2 = (double)t2; // d1 == t2 => evaluates to true somehow? // t1 == d2 => evaluates to true somehow? // d1 == d2 =>…
Luc Bloom
  • 1,120
  • 12
  • 18
7
votes
4 answers

Byte Array to Uint64 as a String

Let's think about the following situation. The Go routine creates a byte array where packs a Uint64 number 5577006791947779410 in 8 bytes Big Endian [77, 101, 130, 33, 7, 252, 253, 82]. In JavaScript code I receive these bytes as Uint8Array. We know…
VisioN
  • 143,310
  • 32
  • 282
  • 281
7
votes
3 answers

how to convert hex string to unsigned 64bit (uint64_t) integer in a fast and safe way?

I tried sscanf(str, "%016llX", &int64 ); but seems not safe. Is there a fast and safe way to do the type casting? Thanks~
Mickey Shine
  • 12,187
  • 25
  • 96
  • 148
7
votes
2 answers

Convert unsigned long long to double in C

I realize this question could be processor dependent, but hopefully someone can point me in the right direction. For the life of me, I cannot figure out how to convert an unsigned long long int representing nanoseconds to a double representing…
shansen
  • 317
  • 1
  • 2
  • 12
6
votes
7 answers

Converting an uint64 to string in C++

What's the easiest way to convert an uint64 value into a standart C++ string? I checked out the assign methods from the string and could find no one that accepts an uint64 (8 bytes) as argument. How can I do this? Thanks
Bilthon
  • 2,461
  • 8
  • 36
  • 44
5
votes
3 answers

Inconveniences of using uint64_t

I have a highly portable library (it compiles and works well everywhere, even without a kernel) and I would like that it remains as portable as possible. So far I have avoided 64bit data types, but I might need to use them now – to be precise I…
madmurphy
  • 1,451
  • 11
  • 20
5
votes
2 answers

PHP 32bit. How to compare uint64 in string and binary representation?

Prerequisites PHP 5.3.6 32-bit (moving to 64-bit is not possible). Need to compare 2 values uint64 (8-byte unsigned integers). One of them I get as string and another as binary string. Question Is it possible to convert string representation of…
5
votes
4 answers

NSString to UInt64

How do you convert from NSString to UInt64? For example, something like this if a UInt64Value helper method existed: NSString *value = @"1234567"; UInt64 convertedValue = [value UInt64Value]; I am trying to do this in an iOS project.
Alexandru
  • 12,264
  • 17
  • 113
  • 208
4
votes
1 answer

UInt64 gets iffy when doing big math?

I have a strange result coming from some big math & have no clue as to why I'm getting a different answer from vb.net vs python. Here are the quick snippets & results: VB.NET Dim MSB As UInt32 = 3067297518 Dim LSB As UInt32 = 1439785590 Dim sqln As…
4
votes
1 answer

Why does different types of array subscript used to iterate affect auto vectorization

As following code shows, why uint32_t prevents the compiler (GCC 12.1 + O3) from optimizing by auto vectorization. See godbolt. #include // no auto vectorization void test32(uint32_t *array, uint32_t &nread, uint32_t from, uint32_t to) { …
Adonis Ling
  • 131
  • 3
4
votes
5 answers

Convert uint64 to GMP/MPIR number

I am using MPIR 2.4.0 on Windows (MSVC 2010) and I was trying to add an unsigned 64bit integer to a mpz_t number. However it seems that MPIR/GMP does not support direct conversion between 64bit Integers and mpz_t. Does this mean I have to convert my…
ThE_-_BliZZarD
  • 722
  • 2
  • 12
  • 26
1
2
3
12 13