Questions tagged [uint]

is a type of variable and is used to store the equivalent of a mathematical non-negative integer

Due to the limited amount of memory a computer can handle, uint can represent just a subset of positive integers.

In C the uint standard is unsigned int and uses 4 bytes of memory (and thus can represents all integers int the range 0 to 4,294,967,295)

192 questions
8
votes
6 answers

C# convert string to uint

So, I have a string of 13 characters. string str = "HELLOWORLDZZZ"; and I need to store this as ASCII representation (hex) in a uint variable. How do I do this?
Andy Hin
  • 30,345
  • 42
  • 99
  • 142
8
votes
2 answers

Are reads and writes for uint8 in golang atomic?

As in the title, are read and write operations regarding uint8, atomic? Logically it must be a single cpu instruction obviously to read and write for a 8 bit variable. But in any case, two cores could simultaneously read and write from the memory,…
Ozum Safa
  • 1,458
  • 2
  • 15
  • 27
8
votes
6 answers

Variable length encoding of an integer

Whats the best way of doing variable length encoding of an unsigned integer value in C# ? "The actual intent is to append a variable length encoded integer (bytes) to a file header." For ex: "Content-Length" - Http Header Can this be achieved with…
Kreez
  • 81
  • 1
  • 1
  • 4
7
votes
3 answers

How can I convert a signed integer into an unsigned integer?

The piece of code is like:- int x = -24; uint y = (uint) x; Console.WriteLine("*****" + y + "********"); // o/p is *****4294967272******** Why this type of behavior in C#, Detailed elaboration would be helpful. Thankyou all.
codemilan
  • 1,072
  • 3
  • 12
  • 32
7
votes
3 answers

Mapping a ulong to a long in C#?

I am trying to map a ulong to a long (and vice-versa), and a uint to a int (and vice-versa), as shown below - in order to save the values in a MS-SQL-database with signed types integer and biginteger only. I do this because I have to check (in the…
user7212775
7
votes
5 answers

Convert -1 to uint C#

Converting -1 to uint will not work "((uint)(-1))" solution? num10 = ((uint)(-1)) >> (0x20 - num9); Error: Constant value '-1' cannot be converted to a 'uint' (use 'unchecked' syntax to override)
user2089096
  • 121
  • 1
  • 1
  • 2
7
votes
2 answers

uint8_t does not take two digit inputs

This is my test code #include using namespace std; int main() { uint8_t a; while(1) { cin>>a; if(a == 0) break; cout<<"Input is "<
Nick
  • 949
  • 1
  • 11
  • 31
5
votes
2 answers

Why does the multiplicative inverse of 0 result in infinity?

I am writing a program in Swift that takes the multiplicative inverse of random bytes. Sometimes, the byte is 0, and when the multiplicative inverse is taken, it results in inf. The multiplicative inverse is being determined using powf(Float(byte),…
Todd
  • 500
  • 4
  • 10
5
votes
3 answers

Better way to calculate difference between numpy unsigned ints in Python

I am calculating the absolute difference between two numpy.uint8s in python with d = abs(a - b), which results in an overflow error if b is bigger than a. What's the best way to avoid this?
blues
  • 4,547
  • 3
  • 23
  • 39
4
votes
1 answer

Arithmetic operation resulted in an overflow in unsafe C#

Background We've been using some code copied verbatim from Joe Duffy's "Concurrent Programming on Windows" (page 149) in production for over a year. The code (below) is used in our Asp.Net web application to probe if there's enough stack space. Our…
Daniel James Bryars
  • 4,429
  • 3
  • 39
  • 57
4
votes
1 answer

iOS and Android AES Encryption (No UINT in Java)

All, I am new to encryption so I'm not sure all of the information I need to share to get help; but I'll edit this question as I learn more about how to ask this question well :) I am performing AES encryption on both an iOS and an android app that…
Eric
  • 1,392
  • 17
  • 37
4
votes
4 answers

sscanf seems to behave different on uint variables vs int variables in c

I am developing a microcontroller program and want to read digits from a string into integer variables using sscanf(). The problem is I get a different behavior when using int declarations vs uint8_t or uint16_t. This is using int for variable…
vbretsch
  • 43
  • 5
4
votes
3 answers

Cast a 10 bit unsigned integer to a signed integer in python

I have a list of numbers in the range 0-1023. I would like to convert them to integers such that 1023 maps to -1, 1022 maps to -2 etc.. while 0, 1, 2, ....511 remain unchanged. I came up with a simple: def convert(x): return (x - 2**9) % 2**10 -…
Fra
  • 4,918
  • 7
  • 33
  • 50
4
votes
4 answers

copying the value of a const uint * to another variable in c++

I have a generic problem I suppose. I`m currently learning C++ and SDL 2.0. SDL provides a function which returns a pointer to a const uint * containing all the keystates. These are the variables I would like to use: const Uint8*…
Symphlion
  • 63
  • 1
  • 5
4
votes
2 answers

cuda integer of 16 bits

is there any 16 bits long variable in CUDA? I need an unsigned integer of 16 bits. I've tried: uint16 uint16_t But no one is recognized by nvcc.
Frederico Schardong
  • 1,946
  • 6
  • 38
  • 62
1
2
3
12 13