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
8
votes
1 answer

64 bit integers and older C++ compilers

I want to use 64 bit integers in my C++ code. I understand I can either #include and then declare a uint64_t or use unsigned long long (or the equivalent for signed versions). However, it appears that support for this was not added until…
Simd
  • 19,447
  • 42
  • 136
  • 271
8
votes
4 answers

long long vs int multiplication

Given the following snippet: #include typedef signed long long int64; typedef signed int int32; typedef signed char int8; int main() { printf("%i\n", sizeof(int8)); printf("%i\n", sizeof(int32)); printf("%i\n",…
azraiyl
  • 343
  • 2
  • 4
  • 11
7
votes
4 answers

3 * 1000000000 overflows as an int, but the variable is long long. Why?

I have a simple c++ app that performs the following calculations long long calcOne = 3 * 100000000; // 3e8, essentially long long calcTwo = 3 * 1000000000; // 3e9, essentially long long calcThree = 3 * 10000000000; // 3e10, essentially If I…
John Voss
  • 107
  • 1
  • 4
7
votes
1 answer

Troubling converting string to long long in C

I'm having trouble getting the atoll function to properly set a long long value in c. Here is my example: #include int main(void) { char s[30] = { "115" }; long long t = atoll(s); printf("Value is: %lld\n", t); return…
Justin Brown
  • 101
  • 1
  • 1
  • 7
6
votes
2 answers

cpp: eclipse doesn't recognize 'long long' type

I have some where in my code the next line: long long maxCPUTime=4294967296; (the largest number long type can be is 4294967296 -1 , so I used long long) the problem is, when I compile ,I get the next error: error: integer constant is too large…
kakush
  • 3,334
  • 14
  • 47
  • 68
5
votes
3 answers

-9'223'372'036'854'775'808LL is unsigned

Since C++20 two's complement representation is the only representation allowed by the standard, with the guaranteed range from -2N-1 to +2N-1-1. So for a 64-bit signed integer type the range goes from -9'223'372'036'854'775'808 to…
user7769147
  • 1,559
  • 9
  • 15
5
votes
3 answers

Casting to long long (GCC)

long long x; double n; x=long long(n); This doesn't work. What is the correct way?
Roamer
  • 63
  • 1
  • 4
5
votes
1 answer

How to silence long long integer constant warning from GCC

I have some code using large integer literals as follows: if(nanoseconds < 1'000'000'000'000) This gives the compiler warning integer constant is too large for 'long' type [-Wlong-long]. However, if I change it to: if(nanoseconds <…
Riot
  • 15,723
  • 4
  • 60
  • 67
5
votes
2 answers

Size of "long long" in 128-bit machine?

In a 128-bit RISC-V (or other 128-bit machine), how big are "long" and "long long" data types in C/C++? To clarify: what are the sizes that an implementer of a compiler might be expected to use when writing the limits.h file for such a machine, in…
Ivan Godard
  • 361
  • 4
  • 5
4
votes
2 answers

C++ Why does LLONG_MIN == -LLONG_MIN

In C++ if I do this: __int64 var = LLONG_MIN; __int64 var2 = -var; cout << "var: "<< var << endl; cout << "var2: "<< var2 << endl; The output I get is: var: -9223372036854775808 var2: -9223372036854775808 What is the part of the standard that…
user2672807
  • 1
  • 2
  • 7
  • 20
3
votes
2 answers

Why would you ever add 10^9+7 to a number and then take mod with 10^9+7

I was solving a problem of Fenwick tree named shill and wave sequence and it wasn't passing all the test cases until I added a line looking at the solution and now want to find its purpose ,here is my code #include using namespace…
3
votes
3 answers

Using preprocessing directive #define for long long

#include using namespace std; #define ll long long int main() { int a = 5; ll maxi = 1; maxi = max(maxi, maxi * ll(a)); cout<
coder_12
  • 33
  • 1
  • 4
3
votes
3 answers

grabbing upper 4 bytes of a 8 byte word

I am multiplying 0x1d400 * 0xE070381D. When I do this on my calculator the result is 0x00019A4D26950400 When I tried implementing this in cpp here's what i have. long long d; d = 3765450781 * 1d400; The result this code gives is that d =…
jprince14
  • 191
  • 2
  • 13
3
votes
1 answer

How to handle "type mismatch" in VBA boolean/LongLong array?

When trying to execute below code, I get the VBA error: type mismatch. Anyone know the cause (and solution? :-)) I changed datatypes from Long to LongLong to be able to handle larger numbers. Before this the code (excerpt) was working fine. Private…
Ronald Vonk
  • 73
  • 1
  • 4
3
votes
2 answers

How can I declare a PtrSafe Sub in VBA? Windows 7, Excel 2016, 64-bit

I am trying to upgrade my large number VBA application from Long datatype to LongLong or LongPtr to be able to handle more digits. But I can't figure out how to call this PtrSafe Sub... Some assistance would be very helpful. I tried a simple example…
Ronald Vonk
  • 73
  • 1
  • 4
1
2
3
8 9