Questions tagged [long-long]

The `long long` size modifier was introduced in C++11 and can be used with integral types to select an integer of at least 64 bits.

See cppreference for more information.

131 questions
1
vote
1 answer

Why can I not initialize a long long as expected?

My VC2017 compiler is showing this behavior, can someone explain me what is going on?: long long testLLSigned0 = LLONG_MIN; // OK, equal to -922129006921510580 long long testLLSigned1 = -922129006921510580i64‬; // Error, invalid suffix i64 on…
jaques-sam
  • 2,578
  • 1
  • 26
  • 24
1
vote
2 answers

Using long long integer to store 32 bit pointer causes printf to bug

Messing around a bit with C pointers, I came across a rather strange behavior. Consider the following code : int main () { char charac = 'r'; long long ptr = (long long) &charac; // Stores the address of charac into a long long variable …
programmersn
  • 582
  • 1
  • 3
  • 17
1
vote
4 answers

Power for big numbers modulo m in C

I am using the following function to compute powers of big numbers modulo m, where m is any integer,i.e. (a^b)%m long long power(long long x, long long y, long long p) { long long res = 1; // Initialize result x = x % p; // Update x…
Klasen
  • 159
  • 1
  • 7
1
vote
4 answers

Returning a long long value

#include int main(void) { long long x = test(); printf("%lld\n", x); return 1; } long long test() { return 1111111111111111111; } The output is 734294471 . If I replace the call to test() by a the number, the…
Pulkit Sinha
  • 2,654
  • 4
  • 19
  • 20
1
vote
0 answers

thrust ignores long long

Thrust treats long long int as if it were long int. Here's a demo program: #include #include void tryit(long long int n) { // with long long long long int s =…
WRF
  • 127
  • 10
1
vote
1 answer

Declaring a long long array with unsigned int size

I was doing a problem when I encountered a segmentation fault while declaring an array as: long long ways[max+1]; where, unsigned int max = findMax(l,T); // l is an unsigned int array and T is an int. and findMax is a function of the type:…
Chandan
  • 166
  • 2
  • 18
1
vote
1 answer

Does elegant way exist to convert double to long long?

I want to get integer part of double. But this way does not work for me: double param, fractpart, intpart; param = 3.14159265; fractpart = modf (param , &intpart); printf ("%f = %f + %f \n", param, intpart, fractpart); It is due to the fact, that…
Denis
  • 3,595
  • 12
  • 52
  • 86
1
vote
1 answer

GCC ARM C compiler not respecting -std=c99 for %llx printf formatting code

I'm trying to print some 64-bit unsigned integers using something like this: uint64_t x = 0xFFFFFFFFFFFFFFFF; printf("Value: %016llx \n", x); and I get this in response: 0000000000000000lx If I change the formatting string to %016lx I get a…
1
vote
1 answer

Fast input for long and long long in C?

So i have been using this function for codechef problems for quite some while now as a fast input method for integers. My question is how this actually works,what is fgetc_unlocked(stdin) (even though its commented) and most importantly how can I…
dannysood
  • 1,129
  • 3
  • 18
  • 36
1
vote
3 answers

Unsigned char array casting to long long

I'm not sure if this is correct, I have tested it and seems that some bytes are off... Basically, I have the following: unsigned char szBuffer[1024] = {0}; long long nValue = 1334553536; memcpy(szBuffer, (char*)&nValue, sizeof(long long)); // long…
Andy Carter
  • 201
  • 3
  • 12
1
vote
2 answers

Bitwise operations on 64-bit data type (long long) in C?

Here is some code. long long bitmap2 = 1; printf("%d\n", bitmap2 & 1); The output is 0, but I am expecting 1. How can I fix this? (I have tried 1LL instead of 1 and uint64_t instead of long long; both gave the same answer of 0.)
1
vote
2 answers

64-bit G++ 4.6.3 doesn't treat longs as long longs in specialised function templates, even though they're the same size. Is this a bug?

Consider the following code: #include #include template void f(); template<> inline void f() { std::cout<<"f()"<
Ose
  • 726
  • 7
  • 13
0
votes
1 answer

How can I work around datatype size limitations?

I have a game on the App Store and I'm getting reports that scores are in accurate and incorrectly reported. I'm using long long for just about all my math. Unfortunately, at about two billion, my math starts fizzling out because the scores are…
Moshe
  • 57,511
  • 78
  • 272
  • 425
0
votes
4 answers

long long int arithmetics

I have the following in C: long long int a; long long int b; long long int c; long long int d=a*b/c; However, I want 'd' to be double. Is there a way I can multiply, divide long long int and get a double as an answer keeping up to 3 decimals as…
Syntax_Error
  • 5,964
  • 15
  • 53
  • 73
0
votes
1 answer

Long Long, decimals and input validation in C

Currently I'm using TCC as it's the easiest thing to get setup on windows. Simply unzip and you're ready to go. However I'm open to other compilers, GCC, whatever microsoft has on offer etc. My problem is that I need to validate the input to a size…
TheIronKnuckle
  • 7,224
  • 4
  • 33
  • 56
1 2 3
8 9