Questions tagged [uint32-t]

uint32_t is 32-bit unsigned integer type. To get this type in your program include or . (corresponding C++ files if you want these types in a C++ code)

Use PRIu32 and SCNu32 to print and scanf this type.

73 questions
1
vote
2 answers

Crypto++ convert Adler32 digest (byte array) to uint32_t

I have the following problem: I'm trying to calculate the adler32 checksum of a data block using Crypto++, but I get the wrong checksum after converting the byte[4] array output to a uint32_t. This function with crc32 works just…
Fabian
  • 152
  • 2
  • 14
1
vote
2 answers

Using ntohl on Struct or Union

ntohl takes a uint32_t. I have messages with many different members (of type uint32_t or uint16_t). Is it possible to properly pass in the entire received struct or union and have it converted to say uint32_t and then reinterpret_cast into my union…
user195488
1
vote
0 answers

c++ why struct with uint32_t and struct with uint8_t[4] have different sizes?

I have two structs: struct struct_A { uint8_t v1[4]; // 4 bytes uint8_t v2; }; struct struct_B { uint32_t v1; // 4 bytes uint8_t v2; // 1 byte }; I obtain their sizes by using the code: std::cout<<"size of struct_A is:…
1
vote
1 answer

Reading in exactly N bytes from standard input in C

I have to read exactly 4 bytes from standard input and then to treat it like a little endian and to display it on standard output but I don't know if what I read is exactly 4 bytes. I tried this: #include #include #include…
1
vote
2 answers

I need to find maximum int32_t number without using constants like INT32_MAX, INT_MAX, etc

So I have a task to check for overflow when adding two int32_t numbers. In case of overflow my function must return maximum or minimum number of int32_t, depending on the sign of overflow, but using constants like UINT32_MAX is restricted. How do I…
Demo_13B
  • 45
  • 1
  • 3
1
vote
2 answers

Access violation when converting from uint32_t to wchar_t and storing in wstring

This might be a simple question, but I have a value in DirectXTDK that is in uint32_t. I would like to display this by concatenating it with a wchar_t. This is what I have so far - char buffer[1]; wchar_t* ws1 = (wchar_t…
firepro20
  • 63
  • 1
  • 8
1
vote
3 answers

How do I change the value of a single byte in a uint32_t variable?

I have an assignment that requires me to read in a picture file as uint32_t variables for each pixel (3 bytes for color and 1 for saturation). I'm then supposed to filter the picture in various ways, such as a red filter where you set all the blue…
Jon D.
  • 27
  • 2
1
vote
2 answers

Combining 2 uint16_t into into 1 uint32_t

I have 2 uint16_t's that i want to combine into 1 32 bit number: uint16_t var1 = 255; // 0000 0000 1111 1111 uint16_t var2 = 255; // 0000 0000 1111 1111 uint32_t var3 = (var1 << 16) + var2; I expect var3 to be 0000 0000 1111 1111 0000 0000 1111…
user4292309
1
vote
0 answers

Trouble printing hex values with vector using printf

My issue is simple: uint32_t memory::read_word1 (uint32_t address) { if(address>(maxWord)){ return 0; } uint32_t temp = 10; return temp; } uint32_t memory::read_word2 (uint32_t address) { if(address>(maxWord)){ …
Dave
  • 454
  • 1
  • 7
  • 17
1
vote
1 answer

Getting the value of a C 4-byte string as a uint

Briefly, my problem is: I'm building a dynamic memory manager, which contains various different kinds of objects. I'm marking each different kind of object with a tag, and, to make memory debugging easier, I want those tags to appear in memory as…
Simon Brooke
  • 162
  • 2
  • 8
1
vote
1 answer

In python: unable to convert variable with uint32_t, uint8_t, int16_t value to hexadecimal

I have a .ini file with values as below [Value1] data_type = uint16_t value = 0x0001U [Value2] data_type = uint32_t value = 0x00000002UL [Value4] data_type = uint8_t value = 5U I am unable to convert these values to hexadecimal as…
Ravi Yadav
  • 405
  • 4
  • 16
1
vote
1 answer

Meaning of *((uint32_t*)&..) in C

LPC_CAN1->TDA1 = *(uint32_t *) &msg->data[0]; // Write first 4 data bytes please tell me why this *(uint32_t ) is used and what is the purpose of this "" before and after the uint32_t
umar.121
  • 21
  • 5
1
vote
3 answers

Multi-precision addition implementation

I am trying to implement multi-precision arithmetic for 256-bit operands based on radix-2^32 representation. In order to do that I defined operands as: typedef union UN_256fe{ uint32_t uint32[8]; }UN_256fe; and here is my MP addition…
A23149577
  • 2,045
  • 2
  • 40
  • 74
1
vote
1 answer

correct use of malloc in function with passed uint32_t array pointer

I'm having difficulty using malloc in a function where I read a binary file with 4 byte unsigned integers, free the passed array reference, remalloc it to the new size and then try to access members of the array. I think the problem is due to the…
Pete
  • 335
  • 1
  • 3
  • 12
1
vote
2 answers

Convert uint8_t hex value to binary

So like it says in the title I am trying to convert a hexadecimal into a binary. But the problem I have been facing is that, the given value is an uint32_t type. So far, I have convert from uint32_t to uint8_t such each of the uint8_t variables…
user2948246
  • 75
  • 4
  • 10