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
votes
3 answers

truncated integer division removal

How do T avoid truncated integer division in this code? My sorted array is 1 1 1 1 1 1, so a[0] = 1 and a[n] should be 1 / 2 = 0.5. int main() { long long n,w; scanf("%lld %lld", &n, &w); long long arr[2*n]; for(long long i = 0; i <…
satyajeet jha
  • 163
  • 3
  • 12
-1
votes
1 answer

long long variable doesn't show correct answer

its some miscalculation. I am in trouble with large numbers. this code works for some smaller inputs(N) but for inputs like 100000 it doesn't. the correct final answer of result variable when N = 100000 must be 4999949998 but result in this code is…
mama23n
  • 135
  • 2
  • 3
  • 10
-1
votes
3 answers

Impossible to print a long long integer in C

I know there are many topics on this subject but none of them helped me to fix my problem. I work on Code::Blocks (with the option -std=c99 in "Properties>Project Build Options>Compiler Settings>Other Options") and the following code doesn't give…
fonfonx
  • 1,475
  • 21
  • 30
-1
votes
1 answer

Error in Printing a long long int

I'm new to C++. I have written a program that uses unsigned long long int data type. I am not able to print the variable properly here is the code: #include #include #include #include #include…
Aneesh K
  • 147
  • 2
  • 10
-2
votes
1 answer

C++ count digit of factorial of a large digit, two digit number or more

Click Here to View CodeFunction to perform factorial of digit and count the number of digit of that factorial When i give "Input:13" this code give the desired output but when i use a "Input: digit greater the this or 3 digit number" then it is…
-2
votes
2 answers

Explicit (long long) conversion of arithmetic expression returns 0

When I multiply a long long value with a double value, I get a double value. To convert it back to long long, I use (long long). But the output I get is 0, when it should be 10. This is my code: #include using namespace std; int…
-2
votes
3 answers

C program using recursion need to get optimised and fixed

I was solving a task that was - a user is entering 3 numbers, a, b, c. The goal is to find if you can get to c summing a and b. In each step is allowed to add a to b, and b to a. I need to find if that is possible with the entered numbers. The…
Juzles
  • 19
  • 6
-2
votes
2 answers

Long data type calculation - Why is Java much faster than C++

I wrote some code both in C++ and in Java to see which will run faster. All this code does is it basically increments two variables and then multiplies them. As expected, C++ was slightly faster than Java. Everything was fine until I changed the…
-3
votes
1 answer

Checking overflow long long in C

I want to check variable from fgets isn't overflowing ling long int in C language. I tried this: long long x; fgets(...) ... if(x <= LLONG_MAX && x >= LLONG_MIN) but it is not working because long long int will receive too large number; it goes…
mlabuda2
  • 28
  • 5
-3
votes
1 answer

C++ long long issues

I've been using signed long longs and have had weird issues with it - i.e. inconsistent behavior. I.e. long long i; printf("%d", i); This tends to print values which have no relevance to the actual value of i (this also occured with cout). It also…
Cjen1
  • 1,826
  • 3
  • 17
  • 47
-4
votes
2 answers

C: command-line argument as binary not identical to local variable as binary

I have c program that takes in a long long argument. When i try to convert this long to its binary representation then it turns out all wrong. But if i set a long long variable that is equal to the value of the long long argument then i get the…
Nulle
  • 1,301
  • 13
  • 28
1 2 3
8
9