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

Multiplication of large numbers yields wrong value

I have the code long long x = 200000 * 200000; cout << x << endl; it outputs 1345294336 I've tried converting to a string and outputting each digit, and it still outputs the same thing
0
votes
0 answers

Why gdb cast output truncated once input exceed int max?

Example of p/x: (gdb) p/x (long long)-2147483647 #still works $1 = 0xffffffff80000001 (gdb) p/x (long long)-2147483648 #truncated once input exceed max int $2 = 0x80000000 (gdb) p/x (long long)-2147483649 $3 = 0x7fffffff (gdb) whatis $1 type = long…
林果皞
  • 7,539
  • 3
  • 55
  • 70
0
votes
1 answer

C++ Chrono - How to use the duration_cast on std::atomic?

I'm have a class Bar with: class Bar { public: //... private: std::atomic m_keepAlive; } This class have some methods described below. This method gets the epoch in ms: long long Bar::getTimeSinceEpoch() { …
waas1919
  • 2,365
  • 7
  • 44
  • 76
0
votes
2 answers

How can i modulo a big integer value

#include #include using namespace std; #include "md5.h" int main() { MD5 md5; string message = "secretU"; char arr[message.size()]; strcpy(arr, message.c_str()); …
Justpee
  • 181
  • 1
  • 3
  • 11
0
votes
1 answer

C variable specified as a long long but recognized as an int

I'm working on a program that checks the validity of credit card numbers for the CS50 class I'm taking (it's legal I swear haha) and I'm currently working on correctly getting the first two numbers of each CC# to check what company it is from. I've…
0
votes
3 answers

qsort not working properly with long long

I am sorting a two dimensional array a[n][2], with respect to a[i][0],a[i+1][0] breaking ties with non-decreasing a[i][1],a[i+1][1]. qsort is working fine with integer array but not with long long array. Integer array code #include…
Vishal
  • 33
  • 1
  • 5
0
votes
1 answer

Does Visual Studio officially support "%lld" format specifier for __int64?

According to this document https://msdn.microsoft.com/en-us/library/tcxf1dw6(v=vs.140).aspx programmers should printf long long variables with %lld and __int64 variables with %I64d. And according to this document…
Alek86
  • 1,489
  • 3
  • 17
  • 26
0
votes
1 answer

Segmentation fault in scanning long long int in C

I'm trying to write a simple program to calculate the number of common factors for two numbers.I am stuck with segmentation fault(core dumped) occurring while scanning the second number.I don't understand where is the fault? #include…
Vishal
  • 33
  • 1
  • 5
0
votes
4 answers

How do I use larger integers in a C program?

I'm using Codeblocks and the GNU compiler on a Windows computer. When the compiler runs, it does so under the following conditions: mingw32-gcc.exe -Wall -g -std=c11 -o obj\Debug\main.o My code is as follows: #include #include…
Joseph Mills
  • 137
  • 5
0
votes
2 answers

Invalid operand of types 'long long int' to binary 'operator%'

i am in C++ and I get this error: bool comprovarCodi(long long num, int DC){ bool codi_correcte; int i=0, suma_senars=0, suma_parells=0, suma_total=0, desena_superior, DC_calculat, cont=0; while(num!=0){ num=num/10; cont++; i++; …
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
4 answers

Long long is 8 bytes, meaning?

I've read the answers to the question of why sizeof(long long) is 8 on most systems, but I'm still not sure how to interpret the meaning of them. One of the reasons given is that there is a lot of code 'out there' which assumes that sizeof(long…
0
votes
4 answers

Why won't auto assign values of type long long?

Using auto, I have created a variable number and used cin.get to get the value. I used this code to do so: auto number = cin.get(); cout << typeid(number).name() << endl; It seems that even if I enter a number that is over 2147483647, the value…
Reuben Ward
  • 101
  • 1
  • 9
0
votes
0 answers

Inconsistent behavior between using 64 bit integers and using 32 bit integers

I'm seeing some very strange behavior when using 64 bit integers in a little program I've written. My program does the following... create 2D long long int array (X by Y) Initialize all array indice values from 0 to X*Y -1 Set the first row and…
0
votes
1 answer

Returning boolean value from long long differs

In my app I have a function that returns a bool from a long long value _flightId which is initially assigned 0. At some point before calling the function below it is usually assigned a value. @property (nonatomic, assign) long long flightId; -…
freshking
  • 1,824
  • 18
  • 31
1 2 3
8 9