Questions tagged [uint32]

uint32 is a datatype that represents an unsigned integer and is coded on 32 bits in memory.

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

176 questions
94
votes
2 answers

Difference between uint32 and uint32_t

Possible Duplicate: Difference between different integer types What is the difference between uint32 and uint32_t in C/C++? Are they OS-dependent? In which case should I use one or another?
Maxbester
  • 2,435
  • 7
  • 42
  • 70
58
votes
4 answers

Swift convert UInt to Int

I have this expression which returns a UInt32: let randomLetterNumber = arc4random()%26 I want to be able to use the number in this if statement: if letters.count > randomLetterNumber{ var randomLetter = letters[randomLetterNumber] } This…
67cherries
  • 6,931
  • 7
  • 35
  • 51
52
votes
6 answers

How do I set a UInt32 to its maximum value

What is the maximum value for a UInt32? Is there a way I can use the sizeof operator to get the maximum value (as it is unsigned)? So I don't end up with #defines or magic numbers in my code.
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
23
votes
4 answers

uint32_t vs int as a convention for everyday programming

When should one use the datatypes from stdint.h? Is it right to always use as a convention them? What was the purpose of the design of nonspecific size types like int and short?
Guy
  • 501
  • 2
  • 4
  • 13
22
votes
5 answers

What is the difference between Int32 and UInt32?

What is the difference between Int32 and UInt32? If they are the same with capacity range capabilities, the question is for what reason UInt32 was created? When should I use UInt32 instead of Int32?
Fitzchak Yitzchaki
  • 9,095
  • 12
  • 56
  • 96
19
votes
6 answers

What is the fastest way to count set bits in UInt32

What is the fastest way to count the number of set bits (i.e. count the number of 1s) in an UInt32 without the use of a look up table? Is there a way to count in O(1)?
user1437139
  • 397
  • 1
  • 5
  • 10
17
votes
8 answers

In C# is there any significant performance difference for using UInt32 vs Int32

I am porting an existing application to C# and want to improve performance wherever possible. Many existing loop counters and array references are defined as System.UInt32, instead of the Int32 I would have used. Is there any significant…
Noah
  • 15,080
  • 13
  • 104
  • 148
13
votes
1 answer

What is unquoted `PRIu32` in printf in C?

I am looking at the following code: #include #include int main() { uint32_t total = 0; printf("\tTotal: %"PRIu32"\n\n", total); return total; } How does PRIu32 fit into the printf syntax? I mean, I sorta can…
Alex
  • 947
  • 1
  • 8
  • 25
10
votes
3 answers

Hack to convert javascript number to UInt32

Edit: This question is out of date as the Polyfill example has been updated. I'm leaving the question here just for reference. Read the correct answer for useful information on bitwise shift operators. Question: On line 7 in the Polyfill example of…
9
votes
4 answers

Fastest way to cast int to UInt32 bitwise?

i have some low level image/texture operations where 32-bit colors are stored as UInt32 or int and i need a really fast bitwise conversion between the two. e.g. int color = -2451337; //exception UInt32 cu = (UInt32)color; any ideas? thanks…
thalm
  • 2,738
  • 2
  • 35
  • 49
9
votes
1 answer

When to use size_t vs uint32_t?

When to use size_t vs uint32_t? I saw a a method in a project that receives a parameter called length (of type uint32_t) to denote the length of byte data to deal with and the method is for calculating CRC of the byte data received. The type of…
Boon
  • 40,656
  • 60
  • 209
  • 315
8
votes
3 answers

Compile time checking existence of stdint.h

I'm working with legacy embedded C code which defines the types uint8_t, uint16_t and uint32_t in a header file using the typedef keyword. For discussion, let us say the file typedefs.h contains these definitions. In my new C source module, I…
Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154
8
votes
2 answers

Commutative hash function for uint32_t value pairs

I need a fast, simple hash function that creates a unique identifier for a pair of uint32_t values - so the same hash value for (2,7) and (7,2). Any idea?
plasmacel
  • 8,183
  • 7
  • 53
  • 101
7
votes
3 answers

Cannot convert value of type 'Int' to expected argument type 'UInt32'

I am trying to generate a random number in Swift: var amountOfQuestions = 2 var randomNumber = Int(arc4random_uniform(amountOfQuestions - 1)) + 1 but this results in the error: Cannot convert value of type 'Int' to expected argument type…
Tom Fox
  • 897
  • 3
  • 14
  • 34
6
votes
7 answers

How do I convert byte array to UInt32 array?

Lets say In C++ I got code like this.. void * target uint32 * decPacket = (uint32 *)target; So in C# it would be like.. byte[] target; UInt32[] decPacket = (UInt32[])target; Cannot convert type byte[] to uint[] How do I convert this memory…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
1
2 3
11 12