Questions tagged [long-integer]

A long integer is an integer number, typically twice the size of a standard integer. It is represented by the keyword 'long' in several programming languages.

A long integer is an integer number, typically twice the size of a standard integer. It is represented by the keyword 'long' in several programming languages.

http://en.wikipedia.org/wiki/Integer_(computer_science)#Long_integer

2408 questions
71
votes
6 answers

warning: left shift count >= width of type

I'm very new to dealing with bits and have got stuck on the following warning when compiling: 7: warning: left shift count >= width of type My line 7 looks like this unsigned long int x = 1 << 32; This would make sense if the size of long on my…
Rupert Madden-Abbott
  • 12,899
  • 14
  • 59
  • 74
71
votes
2 answers

Is it OK to compare an int and a long in Java

Is it OK to compare an int and a long in Java... long l = 800L int i = 4 if (i < l) { // i is less than l }
user1472813
  • 719
  • 1
  • 5
  • 3
70
votes
1 answer

What is 1LL or 2LL in C and C++?

I was looking at some of the solutions in Google Code Jam and some people used this things that I had never seen before. For example, 2LL*r+1LL What does 2LL and 1LL mean? Their includes look like this: #include #include…
fersarr
  • 3,399
  • 3
  • 28
  • 35
68
votes
8 answers

How to convert string to long

how do you convert a string into a long. for int you int i = 3423; String str; str = str.valueOf(i); so how do you go the other way but with long. long lg; String Str = "1333073704000" lg = lg.valueOf(Str);
user1072357
66
votes
1 answer

Long vs BigInteger

I understand that both java.lang.Long and java.math.BigIntegercan hold very large natural numbers. I also know Long's max value, but what is the max value for BigInteger? And aside from capacity, would BigInteger ever perform better when working…
Fritz Duchardt
  • 11,026
  • 4
  • 41
  • 60
62
votes
10 answers

Convert python long/int to fixed size byte array

I'm trying to implement RC4 and DH key exchange in python. Problem is that I have no idea about how to convert the python long/int from the key exchange to the byte array I need for the RC4 implementation. Is there a simple way to convert a long to…
cdecker
  • 4,515
  • 8
  • 46
  • 75
62
votes
6 answers

A long bigger than Long.MAX_VALUE

How can I get a long number bigger than Long.MAX_VALUE? I want this method to return true: boolean isBiggerThanMaxLong(long val) { return (val > Long.MAX_VALUE); }
gongshw
  • 832
  • 1
  • 6
  • 11
60
votes
4 answers

How to printf long long

I'm doing a program that aproximate PI and i'm trying to use long long, but it isn't working. Here is the code #include #include typedef long long num; main(){ num pi; pi=0; num e, n; scanf("%d", &n); for(e=0;…
Carlos
  • 601
  • 1
  • 5
  • 3
60
votes
5 answers

"OverflowError: Python int too large to convert to C long" on windows but not mac

I am running the exact same code on both windows and mac, with python 3.5 64 bit. On windows, it looks like this: >>> import numpy as np >>> preds = np.zeros((1, 3), dtype=int) >>> p = [6802256107, 5017549029, 3745804973] >>> preds[0] = p Traceback…
packybear
  • 617
  • 1
  • 6
  • 8
58
votes
8 answers

How to check a Long for null in java

How do I check a Long value for null in Java? Will this work? if ( longValue == null) { return blah; }
BrownTownCoder
  • 1,312
  • 5
  • 19
  • 25
58
votes
2 answers

What happens when I assign long int to int in C?

In a recent homework assignment I've been told to use long variable to store a result, since it may be a big number. I decided to check will it really matter for me, on my system (intel core i5/64-bit windows 7/gnu gcc compiler) and found out that…
Khaloymes
  • 759
  • 2
  • 6
  • 9
57
votes
5 answers

What's the difference between long long and long

What's the difference between long long and long? And they both don't work with 12 digit numbers (600851475143), am I forgetting something? #include using namespace std; int main(){ long long a = 600851475143; }
Hikari Iwasaki
  • 871
  • 2
  • 9
  • 11
55
votes
4 answers

How to convert a hexadecimal string to long in java?

I want to convert a hex string to long in java. I have tried with general conversion. String s = "4d0d08ada45f9dde1e99cad9"; long l = Long.valueOf(s).longValue(); System.out.println(l); String ls = Long.toString(l); But I am getting this error…
user405398
53
votes
5 answers

Is `long` guaranteed to be at least 32 bits?

By my reading of the C++ Standard, I have always understood that the sizes of the integral fundamental types in C++ were as follows: sizeof(char) <= sizeof(short int) <= sizeof(int) <= sizeof(long int) I deduced this from 3.9.1/2: There are four…
John Dibling
  • 99,718
  • 31
  • 186
  • 324
51
votes
5 answers

Convert long to byte array and add it to another array

I want to change a values in byte array to put a long timestamp value in in the MSBs. Can someone tell me whats the best way to do it. I do not want to insert values bit-by-bit which I believe is very inefficient. long time =…
codeObserver
  • 6,521
  • 16
  • 76
  • 121