uint8_t (C language - Type). uint8_t stores an 8-bit unsigned number, from 0 to 255. It is equal to unsigned char.
Questions tagged [uint8t]
272 questions
1
vote
1 answer
Python: how to keep a big numpy array of arrays of floats relatively small?
I have a numpy array created from reading many images with the cv2 package. I read the image in grayscale so the pixel values are from 0 to 255 in which case the type of the data is uint8. This means each data element is of size 1 byte. I create a…

Atirag
- 1,660
- 7
- 32
- 60
1
vote
0 answers
What is the Reason why using does not work with uint8_t?
I tried to modernise C++ code to C++11, converting typedef statements to using statements:
class Configuration {
typedef uint8_t Protocols;
Into:
class Configuration {
using Protocols = uint8_t;
Where I get this error message from Visual…

Flovdis
- 2,945
- 26
- 49
1
vote
0 answers
uint8_t need uint16_t to store values from stringstream
reading an IP address from argv forces me to convert it to uint32_t
this function will do so:
uint32_t convert_string_ip_to_uint32_t (const string & string_ip)
{
stringstream s(string_ip) ;
uint16_t a,b,c,d; //to store the 4 ints
char…

Ste fan
- 31
- 4
1
vote
2 answers
Optimizing Bitshift into Array
I have a piece of code that runs at ~1.2 million runs per second after performing some tasks, the bulkiest is setting a uint8_t array with bitshifted data from two uint32_t pieces of data. The excerpt code is as follows:
static inline uint32_t…

Greg Esposito
- 52
- 8
1
vote
1 answer
invalid types 'uint8_t {aka unsigned char}[int]' for array subscript
I copied a script from a YouTube video because there was no download link to the script, but now i'm always getting the same error message and I don't know what to do. Could you help me?
This is my code:
#include
int ledPassive…

Simon
- 474
- 2
- 4
- 20
1
vote
1 answer
Slice up an uint8_t array
Let's say that I have an array of 16 uint8_t as follows:
uint8_t array[] = {0x13, 0x01, 0x4E, 0x52, 0x31, 0x4A, 0x35, 0x36, 0x4C, 0x11, 0x21, 0xC6, 0x3C, 0x73, 0xC2, 0x41};
This array stores the data contained in a 128 bits register of an external…

Fluffy
- 857
- 1
- 9
- 20
1
vote
2 answers
convert uint8 and uint32 variables to one uint64
I have the following variables.
uint8_t flags;
uint32_t token;
I need to write function that cobine them into one uint64_t, and than parse them back into two variables, one of uint8_t and one of uint32_t.
uint64 convert(uint8_t flags, uint32_t…

Dan The Man
- 1,835
- 6
- 30
- 50
1
vote
2 answers
Converting a uint8_t to its binary representation
I have a variable of type uint8_t which I'd like to serialize and write to a file (which should be quite portable, at least for Windows, which is what I'm aiming at).
Trying to write it to a file in its binary form, I came accross this working…

Asaf
- 2,005
- 7
- 37
- 59
1
vote
2 answers
How to copy uint8_t array in char array in c
I would copy a uint8_t array in a char array.
I tried different solutions with: cast, memcopy, strcpy...
but it does not work!!! My little example is:
uint32_t num = 123456789;
printf("\n num: %"PRIu32 "\n", num);
uint32_t x;
uint8_t a[4];
char…

Peppifg
- 35
- 1
- 8
1
vote
1 answer
Why do windows API calls dealing with bytes (such as 'recv') use char*, which is signed by default?
I'm fairly new to c/c++, and I'm trying to follow some guidelines which suggest using the stdint.h defined types where possible (uint8_t, etc instead of unsigned char).
However, it seems like when you're calling an API which expects a char* buffer…

Twicetimes
- 678
- 1
- 7
- 15
1
vote
1 answer
Value of uint8_t after being converted from uint_16t
I have to do a small assignment for school. I am writing this in C. The question is:
Given
uint16_t A[] = { 0xabce, 0x43fe, 0xcf54, 0xffff };
uint8_t *p = (uint8_t *)&A[0];
What is the value of p[3]?
I did some research and found that the numbers…

LvanRooij
- 86
- 7
1
vote
1 answer
Function imfindcircles Matlab
I'm using the function imfindcircles on image but occurs an error that says that function or method 'imfindcircles' for input arguments of type 'uint8'. I'm using this tutorial of Mathworks. My code:
rgb =…

Pedro Marques
- 175
- 2
- 14
1
vote
3 answers
How to turn a signed integer value to unsigned, according to its bits?
I want to turn a signed value into an unsigned one (for example, int8_t to uint8_t), but also it must keep its bits.
How can I do it?

sator.arepo.tenet.opera.rotas
- 131
- 1
- 1
- 11
1
vote
1 answer
uint16_t uint8_t or size_t?
I would like to use a function which is charged to send both "data size" and "data" to a specific file descriptor by using write(). It works when the record length is equal to 2 bytes. However, I would like to use the same function to send also…

ogs
- 1,139
- 8
- 19
- 42
1
vote
2 answers
C converting 8 bit values into 16 bit values
I have a situation where I pass an array containing 2 1 byte values to a function, but somehow the function thinks the array is 4 bytes long, which messes up my bit manipulation big-time. I even tried explicitly casting each array value as a…

AaronF
- 2,841
- 3
- 22
- 32