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
0
votes
1 answer

Is it safe to compare an (uint32_t) with an hard-coded value?

I need to do bitewise operations on 32bit integers (that indeed represent chars, but whatever). Is the following kind of code safe? uint32_t input; input = ...; if(input & 0x03000000) { output = 0x40000000; output |= (input & 0xFC000000)…
KrisWebDev
  • 9,342
  • 4
  • 39
  • 59
0
votes
4 answers

Create a string from uint32/16_t and then parse back the original numbers

I need to put into a char* some uint32_t and uint16_t numbers. Then I need to get them back from the buffer. I have read some questions and I've tried to use sprintf to put them into the char* and sscanf get the original numbers again. However, I'm…
Fdiazreal
  • 785
  • 1
  • 8
  • 13
0
votes
2 answers

overflow when using uint32_t

#include #include #include char* createMSG(uint8_t i,uint32_t port); int strlen(char* tmp); uint32_t user_port = 5000; int main(int argc, char** argv) { char *msg; uint8_t i; i = 1; msg =…
user1324258
  • 561
  • 2
  • 8
  • 25
-1
votes
2 answers

Understanding uint32_t char typecast (Bytes)

Lets say we have this: int main() { int32_t* value = (uint32_t*)malloc(sizeof(uint32_t)); uint32_t array[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; *value = *(uint32_t*)((char*)array + 8); printf("Value is: %d\n", *value); return…
D idsea J
  • 103
  • 1
  • 8
-1
votes
2 answers

Converting std::string to uint32_t

I have a string like below: std::string strl="ffffffffffffffffffffffffffffffffffffffffffff"; I want to convert it into uint32_t variable like below: uint32_t val = std::stoul(strl, nullptr, 16); The above operation gives a "SIGABRT" signal and…
Santosh Sahu
  • 2,134
  • 6
  • 27
  • 51
-1
votes
3 answers

Split parts of a uint32_t hex value into smaller parts in C++

I have a uint32_t as follows: uint32_t midiData=0x9FCC00; I need to separate this uint32_t into smaller parts so that 9 becomes its own entity, F becomes its own entity, and CC becomes its own entity. If you're wondering what I am doing, I am…
Midimistro
  • 315
  • 2
  • 12
-2
votes
1 answer

Encode and combine int to 32bit int in C binary file

Lets say I have 2 variables: int var1 = 1; //1 byte int var2 = 2; //1 byte I want to combine these and encode as a 32bit unsigned integer (uint32_t). By combining them, it would be 2 bytes. I'd then fill the remaining space with 2 bytes of 0…
Alex
  • 49
  • 7
-2
votes
2 answers

C++ equality for uint32_t type not comparing

I am reading RFID cards and trying to compare the ID's as once the card passes the reader, the reader actually reads it more than once so I need to discard the duplicates. UPDATED : The following code gets the cards ID's uint32_t…
dinotom
  • 4,990
  • 16
  • 71
  • 139
-2
votes
2 answers

C global variable value is not kept outside of function

I'm running into a slightly embarrassing problem: I have a program with two global uint32_t variables, and a function in which I assign values to them. However, when I try to print/access these values later on, one gives me the correct value, while…
Linus
  • 1,113
  • 1
  • 8
  • 14
-3
votes
1 answer

include iostream breaks uint32_t definition (C)

Edit: Please disregard this question. I realized that I am an idiot and very nice and helpful people pointed out iostream is not a C but a C++ library. I am encountering a very strange problem. I have a fully working program (about 1000 lines). I…
Duxa
  • 966
  • 2
  • 14
  • 27
-3
votes
2 answers

Why is the result of uint32_t becoming octal number automatically?

int main() { uint32_t n1 = 00000000000000000000000000001000; uint32_t n2 = 00000000000000000000000000000100; cout << n2; } When I use Visual Studio 2013 (C++), I am getting the result as 64. Why is this turning to octal number system…
-4
votes
2 answers

how should i convert a uint32_t value into a char array of size 32?

(uint32_t header;char array[32];) how do I copy the data from header to array in c++ ? how to carry out this conversion ? I tried type -casting, but it doesn't seem to work .
-4
votes
1 answer

C++ - Self made Big integer class gives errors

I'm working on a piece of code that can can handle big integers build out of 4 uint32_t elements. I've created a class called BigInteger, and a few operators. The problem is that I get some errors, but I do not see what is going wrong. I've added…
qweabc
  • 15
  • 2
1 2 3 4
5