Questions tagged [unsigned-long-long-int]

unsigned long long int specified in the C99 standard

unsigned long long long int is at least 64-bit in size and was specified in the C99 standard. It is the same as long long but unsigned.

162 questions
0
votes
2 answers

How to correctly multiply two long long ints?

I want to multiply long numbers which are given in a 2^32 basis. I already thought of an nice algorithm to do that, but unfortunatly I'm stuck. The situation I'm stuck at, is how I do multiply two long ints and represent it on the 2^32…
citronas
  • 19,035
  • 27
  • 96
  • 164
0
votes
1 answer

Formatting of an unsigned long long causes an integer overflow

The unsigned long long type doesn't work as expected for me. Here's my simple code: #include #include int main(int argc, char *argv[]) { unsigned long long a = 2932306814; printf("a = %d\n", a); return…
Danny Lo
  • 1,553
  • 4
  • 26
  • 48
0
votes
1 answer

C how to retrieve exact double value (precision) from a unsigned integer

I have a checksum which I am trying to reverse engineer, I already know how to keep the checksum generating after I know the original initial value that was used to create the checksum in the first place. So far I know the checksum is generated…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
0
votes
1 answer

Unsigned long long wrong given value after add

I have two strings to add. Strings is HEX values. I convert strings to long long, add and after I back to string. But this operation no working good. Code: unsigned long long FirstNum = std::strtoull(FirstString.c_str(), NULL, 16); unsigned long…
ventaquil
  • 2,780
  • 3
  • 23
  • 48
0
votes
2 answers

Math Error with Primitive Operators

I am having an issue with primitive types using built in operators. All of my operators work for all datatypes except for float and (un)signed long long int. Why is it wrong even when multiplying by one? Also, why does +10 and -10 give the same…
tkellehe
  • 659
  • 5
  • 11
0
votes
1 answer

What should be the data type for numbers in between the range of 10^10 - 10^11?

Suppose I have the following code to loop over numbers as follows: int p; cin>>p; for(unsigned long long int i=3*pow(10,p);i<6*pow(10,p);i++){ //some code goes here } Now, based on certain condition checks I need to print a i in…
Abrar
  • 6,874
  • 9
  • 28
  • 41
0
votes
2 answers

C++ overflow detection for large numbers (unsigned long long)

I am dealing with large integers (unsigned long long) and need to guard for overflow conditions. The code throws the exception regardless if there actually is one: try { unsigned long long y = std::numeric_limits::max() - 2; …
Vectorizer
  • 1,076
  • 9
  • 24
0
votes
1 answer

generate positive random number and right shift by 8 bits and store in a byte

I am struck at writing a java equivalent code for a C code to generate random number. The C code is as follows : static void lng_cosem_CreateRandom(u8 *u8p_Array_p, u8 u8_Len_p) { u8 u8_Indx; …
Abinaya
  • 23
  • 7
0
votes
1 answer

Bitwise operations on unsigned long long in c

I've stumbled upon a following problem, could anyone please help? I'm trying to use bitwise operations, and I'm expecting this to print the value of 2^50. The output, however, is 0. The maximum I can get it to print is 2^31, which is supposed to be…
Marcin
  • 380
  • 3
  • 20
0
votes
1 answer

Core Data unsigned long long best practice

I need to store uint64_t number in Core Data property. I also need to use this property in predicate. The problem is, Core Data only has Integer64 type, and I can't perform fetch request on that property. For example: NSNumber *pid =…
Eyal
  • 10,777
  • 18
  • 78
  • 130
0
votes
2 answers

C program to find the n'th prime number-

#include #include #include int prime(long long int); long long int *arr; //array to hold n prime numbers int main() { int i,count=4;; long long int n; scanf("%lli",&n); arr=malloc(sizeof(long…
Devarshi
  • 11
  • 1
0
votes
2 answers

unsigned long int giving integer overflow

I am trying to create a program in c to solve sudoku puzzles,in which i am trying to store a number equal to 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 in an unsigned long int variable. on compiling with boath gcc and g++ on a 32 bit Ubuntu…
Prakhar Thakur
  • 1,209
  • 3
  • 13
  • 38
0
votes
4 answers

java converting int to short

I am calculating 16 bit checksum on my data which i need to send to server where it has to recalculate and match with the provided checksum. Checksum value that i am getting is in int but i have only 2 bytes for sending the value.So i am casting int…
changed
  • 2,103
  • 8
  • 36
  • 56
0
votes
1 answer

Datatype which can store very large value in C

Recently in programming contest in Here, the problem is pretty straight forward but catch is with worst case scenario which we have to handle data of size 10^10000 . I tried the program in python which is straight forward as i don't have to specify…
KARTHIK BHAT
  • 1,410
  • 13
  • 23
0
votes
1 answer

handling overflow in Objective C

I'm building a hex calculator in objective-c. My problem is dealing with long long values that would overflow when multiplied. When I add values before I add i check that the value would not overflow by doing something like this. long long…