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
-1
votes
2 answers

uint32_t has 28 bits instead of 32 bits

I've encountered a confusing situation. I have this simple addition inside my code: temp = thi + t2lo; I have defined thi and t2lo as uint32_t in my code and temp as uint64_t: uint32_t thi, tlo, t2hi, t2lo; uint64_t temp = 0; My code doesn't work…
A23149577
  • 2,045
  • 2
  • 40
  • 74
-1
votes
1 answer

(float32) 4 bytes (uint8) into a float64 (c++/C)

I have a uint8 vector (in a IEEE 32 float number), with the size of 4, and I want to convert to a float64, What is the best way to do this in C++/C? I am doing float a=*(float *) my_pointer, however my compiler is using a float64, which creates a…
user3197577
  • 1
  • 1
  • 2
-1
votes
3 answers

How to shift a bits in a Ushort 16 bit integer in VB.NET?

I have a 16 bit unsigned integer and its values are like this: byte_val1 = 1000000000000001 From this I need to right shift this and make it like this: 1100000000000000 I have done this: byte_val1 = byte_val1 >> 1 and getting byte_val1 =…
Arindam Das
  • 699
  • 4
  • 20
  • 39
-2
votes
1 answer

How to cast from a Go pointer to uintptr and back without a memory corruption?

Conversion between pointers should be made using unsafe.Pointer() and uintptr. I am writing an interpreter using Go. This is very simple fragment using an EID struct to carry pairs (type,values) between different sections of native code. This code…
Yves Caseau
  • 1
  • 1
  • 2
-2
votes
2 answers

replicate javascript unsafe numbers in golang

So in go, I do a calculation which gives "5726718050568503296" In JS it gives "5726718050568503000" I would like to replicate this behavior in go
user41599
  • 7
  • 4
-2
votes
3 answers

How to convert uint to bool array?

for example uint <- 1 I want to get 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 if uint <- 8 get it 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Just format by bit , How can I do?
TimChang
  • 2,249
  • 13
  • 25
-2
votes
1 answer

negative cannot be converted to a uint

I was looking to convert some old code I found to a .net standard compliant version. However I haven't used code like this before so I'm a bit lost on how to use it as it doesn't compile. I understand that uint cannot be negative but how did this…
danewfie
  • 13
  • 3
-2
votes
2 answers

Placing uint32_t into array of uint8_t

So I have the following code: uint32_t length = 1; uint8_t buffer[5]; buffer[0] = htonl(length); std::cout << (uint32_t)*buffer << std::endl; std::cout << htonl(length) << std::endl; The second to last line prints out 0, the last line prints out…
Ethan
  • 1,206
  • 3
  • 21
  • 39
-2
votes
2 answers

Converting ASCII to uint8

I need to send some number sequences to a microcontroller. Here is my function: void DriveForward() { printf("137 0 0 128 0"); } The micro does not accept ASCII while my function sends as ASCII. I need to send that ASCII…
Dumbo
  • 13,555
  • 54
  • 184
  • 288
-3
votes
1 answer

uint(-5.0), where parameter is a float64, = 18446744073709551611?

In the Tour of Go, step 13, I changed a bit the script package main import ( "fmt" "math" ) func main() { var x, y int = 3, 4 var f float64 = math.Sqrt(float64(x*x + y*y)) var z uint = uint(f) fmt.Println(x, y, z,…
Marc Le Bihan
  • 2,308
  • 2
  • 23
  • 41
-4
votes
2 answers

When trying to print UINT_MAX I get -1

When trying to print 'UINT_MAX' all I get it -1, why is this? It's the only thing I have in my 'main()', a printf statement that prints 'UINT_MAX'
Jordan Baron
  • 165
  • 1
  • 15
-7
votes
2 answers

error: invalid conversion from 'char*' to 'uint32_t

I am trying to manually set up a RTC clock. When doen automatically, this is the working code: clock.setDateTime((__DATE__, __TIME__)); But now I want to set it manually and this is what I am trying: char dateTime[20]; strcat(dateTime,…
sdd
  • 889
  • 8
  • 29
1 2 3
12
13