Questions tagged [uint16]
127 questions
3
votes
1 answer
C++ Getting WMI Array Data from the Local Computer
I am facing problem in retrieving array data from a WMI class using c++.
In the following link, http://msdn.microsoft.com/en-us/library/aa390423(v=vs.85).aspx, step 7 of the example shows us how to retrieve a string value of the wmi query ran.…

Brumble
- 71
- 1
- 6
2
votes
3 answers
C - convert a struct in a u16_array, where each uint16_t represents only a byte
I have a pretty nasty case on a texas instruments C2000 microcontroller, that is only available to represent uin16_t and not uint8_t. Now I have a struct like the following, where each uint16_t represents only a byte of data, that will be written to…

HansPeterLoft
- 489
- 1
- 9
- 28
2
votes
1 answer
Visual Studio C++ has different comparison results for UINT16 and UINT32
I caught myself checking if the difference between two unsigned numbers was >= 0. I ran a test running Visual Studio 2022 Preview with the following code. In both cases the answer was true. That seems right to me as how could an unsigned number be…

MaryK
- 71
- 6
2
votes
1 answer
Safe way to get number of bytes for a data type in C++
I'm using C++11 and higher and I was asking myself if it is safe to get the number of bytes required for a datatype like std::uint16_t to send over length agnostic protocols. More precise is it safe to call sizeof(std::uint16_t) and can I assume…

Gustavo
- 919
- 11
- 34
2
votes
2 answers
C int memory storage. Least signinficant vs most significant bits?
I'd expect the following combination of two uint8_t (0x00 and 0x01) into one uint16_t to give me a value of 0x0001, when I combine them consecutively in memory. Instead I obtain 0x0100 = 256, which I'm surprised of.
#include
#include…

L. Arnaud
- 55
- 6
2
votes
1 answer
fast way to convert array of 16 bit unsigned interger to bits
I have a large dataset containing a 3d array of 16 bit unsigned integer. I want to convert each of the integer into bits and then only retain whose 8:12 bits are "0000" So far I am using a very slow method of loop in three stages:
import numpy as…

Vinod Kumar
- 1,383
- 1
- 12
- 26
2
votes
2 answers
Casting int16_t to uint_8t*
I have a library driven result stored as an int16_t value (and it is a negative, which I can use the absolute value of) and another library function that requires this value a few steps later in the form uin8_t*. How can this be done without using…

Orbiting Eden
- 1,522
- 13
- 16
2
votes
0 answers
c# ushort uint16 which type to choose
I can't understand why we can have ushort and uint16… 2 bytes for both. But a problem if I want to use Convert. If I remember well it's ushort.parse(stringtype) while convert.touint16 needs an object.
I searched but can't find why… In the past I…
user8888955
2
votes
1 answer
calling uint16 on a rune is big or little endian?
I've got the following Go program:
package main
import (
"fmt"
)
func main() {
r := rune(249)
x := uint16(r)
fmt.Println(x)
}
If I have a rune r and call uint16(r) on it, is it going to be big or little endian encoded? Does Go…

Seneca
- 2,392
- 2
- 18
- 33
2
votes
2 answers
How to convert UInt16 to UInt8 in Swift 3?
I want to convert UInt16 to UInt8 array, but am getting the following error message:
'init' is unavailable: use 'withMemoryRebound(to:capacity:_)' to
temporarily view memory as another layout-compatible type.
The code:
let statusByte: UInt8…

JTing
- 651
- 7
- 17
2
votes
1 answer
Matlab int16() C equivalent?
In Matlab there is a function called int16, that rounds e.g. double values to the next integer. Is there any simple equivalent in C to that?
Especially for the rounding of negative numbers, e.g. -1.65 to -2 and 1.33 to -1.

Alex
- 155
- 1
- 2
- 10
2
votes
1 answer
Why does not uint16_t show the desired output?
I have an array-
uint8_t arrayTest[] = {
0, 0xC1,
0, 0, 0, 0x0a,
0, 0, 0, 0x50
};
So the following printf with uint32_t shows the correct output "a":
printf("%x ",ntohl(*((uint32_t…

rrsuj
- 409
- 6
- 10
1
vote
1 answer
Why is documented Bluetooth Unit8 value being read as a Int16?
What have I tried?
I read through GATT_Specification_Supplement_v10.pdf and previous publicly available versions of the document mentioned.
I looked at stack overflow questions and 3rd party bluetooth libraries.
For 3.125 Indoor Bike Data…

3366784
- 2,423
- 1
- 14
- 27
1
vote
1 answer
Modbus home assistant and python struct (little endian, big endian, negative values from uint16)
I have a question regarding to modbus settings. I have read the documentation carefully, tried to search some topics, but unfortunately I did not find an answer to my problem.
I have a heat pump, which is able to communicate through modbus. In the…

tomdelahaba
- 948
- 3
- 13
- 26
1
vote
1 answer
Kotlin Android Studio how to merge two uint8 to one uint16
I am reading data from bluetooth gatt characteristic. First data is one byte and I am successfully reading it by code:
val strValue = characteristic.value[0].toUByte()
characteristic.value[1] contains most significant byte of…

NIXIE_123
- 11
- 2