long-long Questions

6

Solved

I read that GCC supports the long long int type which is required to be at least 64 bits wide. But how can it make math operations with it on a CPU that is only 32 bits wide?
Boucicault asked 18/6, 2010 at 19:13

7

Solved

Wouldn't it have made more sense to make long 64-bit and reserve long long until 128-bit numbers become a reality?
Araujo asked 2/9, 2011 at 5:20

14

Solved

#include <stdio.h> int main() { unsigned long long int num = 285212672; //FYI: fits in 29 bits int normalInt = 5; printf("My number is %d bytes wide and its value is %ul. A normal number i...
Poulin asked 5/8, 2008 at 20:59

4

Solved

I am having following code. output of second %d in sprintf is always shown as zero. I think i am specifying wrong specifiers. Can any one help me in getting write string with right values. And this...
Lodovico asked 28/2, 2011 at 10:37

3

Solved

Why do many of the online judges advise "do not use the %lld specifier to read or write 64-bit integers in С++"? Is it preferred to use the cin, cout streams or the %I64d specifier?
Acidulent asked 30/3, 2013 at 11:30

5

Solved

In the C99 standard they introduced long long. What is the purpose of this? In my (limited) C programming experience, I've only every seen a 4-byte int and an 8-byte long. For example, from Compile...
Facetious asked 9/1, 2021 at 22:20

4

If I have long long x; in c++, how can I loop over each bit in the number to check if it zero or 1? I would like to count the number of ones in the bits.
Devitrify asked 18/11, 2013 at 18:16

3

Solved

I have an open-source codebase that is written in both C and C++. I'm looking for an integer type that is guaranteed to be at least 64 bits wide, which can be reliably compiled on most OS X (Intel,...
Maes asked 17/9, 2012 at 23:6

3

Solved

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 f...
Haywood asked 18/4, 2020 at 13:52

3

Solved

I'm trying to calculate large integers with the long long datatype but when it gets large enough (2^55), the arithmetic behavior is unpredictable. I am working in Microsoft Visual Studio 2017. In ...
Megrims asked 3/5, 2019 at 13:42

3

Solved

I want to print all bits of a long long number. When I am doing it in main() everything is fine, but in printBits() function (where code is same) there is an extra 1 on 32th bit. The code: #inclu...
Conlee asked 1/5, 2018 at 20:11

2

Solved

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: ...
Outsize asked 8/9, 2013 at 19:15

1

Solved

I want to use 64 bit integers in my C++ code. I understand I can either #include <cstdint> and then declare a uint64_t or use unsigned long long (or the equivalent for signed versions). How...
Santiagosantillan asked 15/6, 2017 at 18:40

4

Solved

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 calc...
Szeged asked 22/3, 2017 at 18:50

5

Solved

We know that -2*4^31 + 1 = -9.223.372.036.854.775.807, the lowest value you can store in long long, as being said here: What range of values can integer types store in C++. So I have this operation...
Linders asked 8/12, 2016 at 15:36

0

I'm trying to understand the requirements for selecting a built-in 64-bit data type using either long or long long. I'm having trouble understanding the type equivalence and the alignment requireme...
Ambrosine asked 31/7, 2016 at 5:50

2

I am trying to find the square of a int. My code looks like below: long long sqr=0; int num=77778; sqr= num*num; The result should have been 6049417284 But when I check the output it shows...
Pause asked 10/6, 2016 at 6:0

2

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 wh...
Eachelle asked 10/8, 2015 at 4:38

1

I'd like to convert a long long to a string in C. long long x = 999; I'd like to convert x to a string. How could I go about doing that? Thanks.
Sabba asked 19/4, 2013 at 0:22

4

Solved

I have two numbers: A and B. I need to calculate A+B somewhere in my code. Both A and B are long long, and they can be positive or negative. My code runs wrong, and I suspect the problem hap...
Fredi asked 10/4, 2013 at 8:26

1

Solved

I'm having trouble getting the atoll function to properly set a long long value in c. Here is my example: #include <stdio.h> int main(void) { char s[30] = { "115" }; long long t = atoll(s...
Portemonnaie asked 14/3, 2013 at 19:15

2

Solved

Consider the following code: #include <iostream> #include <cinttypes> template<class T> void f(); template<> inline void f<long long>() { std::cout<<"f<l...

1

Solved

It says on wikipedia and in Stroustrup's FAQ that type long long is at least as long as an int and has no fewer than 64 bits. I have been looking at the C++11 standard §3.9.1 Fundamental Types sect...
Tibiotarsus asked 7/4, 2012 at 8:49

2

I don't know this type. Is that the biggest one from all? I think it is an integer type, right? Or is it a floating point thing? Bigger than double?
Tarango asked 24/1, 2010 at 15:10

2

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 th...
Overelaborate asked 26/1, 2012 at 8:45

© 2022 - 2025 — McMap. All rights reserved.