|
Long long int A = 3289168178315264; long long int B = 1470960727228416; double D = sqrt(5); long long int out = A + B*D; printf("%lld",out);
This gives result : -2147483648
I am not able to figure out why (it should be a positive result). Can somebody...
Started by Rohit on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
long long int A = 3289168178315264; long long int....
3289168178315264LL should explict cast the result from B * D to long long.
Maybe you have to specify those constants as "long long" literals? e.g.
|
|
From C standard, int has of at least 16bit, long has of at least 32bit and at least 64bit for long long if any (some platforms may not support). Just wondering if the sentence as title is always true.
Thanks.
Started by c-stranger on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Of course, this would be silly <= int <= long
Still searching for long....
Across an implementation in which sizeof(int) > sizeof(long) you have my permission to give, if CHAR_BITS == 8), while long is 32-bits (4 bytes).
|
|
I have a byte array that has hex values and I initially put those values in a unsigned long. I am using a 32 bit processor via Ubuntu at the moment. But, i might have to port this program to a 64 bit processor.
now I am aware of strtoul function but since...
Answer Snippets (Read the full thread at stackoverflow):
Instead of using long or long long you should use a typedef like uint32_t , or something similar}; long* p_long = reinterpret_cast<long*>(bytes); std::cout << std::hex << *p_long if they....
|
Ask your Facebook Friends
|
This sadly doesn't work:
long[] longs = new long[]{1L}; ArrayList<Long> longArray = new ArrayList<Long>(longs);
Is there a nicer way except adding them manually?
Started by ripper234 on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Using ArrayUtils from apache commons-lang
long[] longs = new long[]{1L}; Long[] longObjects; asList(final long[] l) { return new AbstractList<Long>() { public Long get(int i) {return l[i];} // throws NPE....
|
|
Title basically says it all... does GCC support:
long long int
which would be a 64 bit integer?
Also, is long long int part of the standard? Thanks
Started by Polaris878 on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
The standard does not mandate that usually an unsigned ... .
Yes GCC does support long long int , which is a part of C99 standard.
And now I can prove it.
long long int is a part of the C99 standard, and I know GCC supports it.
|
|
Why might using a "long long" in C or C++ be a bad thing?
I was compiling a runtime library the other day and in the code it checks to see if longs are 64bits and if not it uses a long long. But along with that, it sends out a #warning "using long long...
Started by Crazy Chenz on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
If you use an old C compiler, it might not support long long that led to size_....
Two reasons:
You don't know how long (haha!) a long long is, so if the code assumes that it is exactly 64 bits, there could be a problem.
|
|
As per c99 standard, size of "long long" should be minimum 64 bits. How this is implemented in a 32 bit machine(eg. addition or multiplication of 2 "long long"s).
What is the equivalent of long long in C++.
Started by chappar on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
As mentioned earlier....
The next C++ standard (due 2009, or maybe 2010), is slated to include the "long long" type.
It's not required by the standard, but most compilers support for 64-bit operations .
In C++ is long long as well.
|
|
#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 is %d.\n", sizeof(num), num, normalInt);
return 0;
}
Output...
Started by superjoe30 on
, 13 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
Printf("%llu", 285212672); Non-standard things are always strange :)
for the long long portion under GNU it's L , ll or q, instead of 5 as it should.
Use the ll (el-el) long-long modifier with the u (unsigned) conversion.
|
|
In C++, I enjoyed having access to a 64 bit unsigned integer, via unsigned long long int, or via uint64_t. Now, in Java longs are 64 bits, I know. However, they are signed.
Is there an unsigned long (long) available as a Java primitive? How do I use it...
Started by eleven81 on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
You'll have to use the primitive long data type and deal with signedness issues, or use a class.
Once you want to go bigger than a signed long, I think BigInteger is the only, there is not.
I don't believe so.
|
|
Can anyone explain the output of this program and how I can fix it?
unsigned long long ns = strtoull("123110724001300", (char **)NULL, 10); fprintf(stderr, "%llu\n", ns); // 18446744073490980372
Answer Snippets (Read the full thread at stackoverflow):
However main(void) { unsigned long long ns = strtoull("123110724001300", NULL, 10); fprintf(stderr, "%llu\n> int main(void) { unsigned....
Why not use strtoull if you want an unsigned long long?
I cannot explain the behavior.
|