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

What is the conversion specifier for printf that formats a long?

The printf function takes an argument type, such as %d or %i for a signed int. However, I don't see anything for a long value.
Thomas Owens
  • 114,398
  • 98
  • 311
  • 431
445
votes
7 answers

How to printf "unsigned long" in C?

I can never understand how to print unsigned long datatype in C. Suppose unsigned_foo is an unsigned long, then I try: printf("%lu\n", unsigned_foo) printf("%du\n", unsigned_foo) printf("%ud\n", unsigned_foo) printf("%ll\n",…
bodacydo
  • 75,521
  • 93
  • 229
  • 319
321
votes
8 answers

How to convert / cast long to String?

I just created sample BB app, which can allow to choose the date. DateField curDateFld = new DateField("Choose Date: ", System.currentTimeMillis(), DateField.DATE | DateField.FIELD_LEFT); After choosing the date, I need to convert that long value…
user225714
  • 3,211
  • 2
  • 16
  • 5
290
votes
7 answers

What is the difference between "long", "long long", "long int", and "long long int" in C++?

I am transitioning from Java to C++ and have some questions about the long data type. In Java, to hold an integer greater than 232, you would simply write long x;. However, in C++, it seems that long is both a data type and a modifier. There seems…
1110101001
  • 4,662
  • 7
  • 26
  • 48
256
votes
14 answers

How do I convert from int to Long in Java?

I keep finding both on here and Google people having troubles going from long to int and not the other way around. Yet I'm sure I'm not the only one that has run into this scenario before going from int to Long. The only other answers I've found…
Ghosty
  • 3,203
  • 2
  • 18
  • 13
243
votes
4 answers

Initialize a long in Java

Primitive Data Types - oracle doc says the range of long in Java is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. But when I do something like this in my eclipse long i = 12345678910; it shows me "The literal 12345678910 of type int is…
aamadmi
  • 2,680
  • 2
  • 18
  • 21
233
votes
4 answers

What is the maximum float in Python?

I think the maximum integer in python is available by calling sys.maxint. What is the maximum float or long in Python? See also: Maximum and Minimum values for ints.
ladyfafa
  • 6,629
  • 7
  • 26
  • 22
208
votes
18 answers

How do I convert Long to byte[] and back in java

How do I convert a long to a byte[] and back in Java? I'm trying convert a long to a byte[] so that I will be able to send the byte[] over a TCP connection. On the other side I want to take that byte[] and convert it back into a double.
Emre801
  • 3,043
  • 5
  • 25
  • 28
178
votes
11 answers

How to implement infinity in Java?

Does Java have anything to represent infinity for every numerical data type? How is it implemented such that I can do mathematical operations with it? E.g. int myInf = infinity; //However it is done myInf + 5; //returns infinity myInf*(-1);…
user1753100
  • 1,909
  • 2
  • 14
  • 12
171
votes
8 answers

Can I convert long to int?

I want to convert long to int. If the value of long > int.MaxValue, I am happy to let it wrap around. What is the best way?
Ian G
  • 29,468
  • 21
  • 78
  • 92
158
votes
4 answers

Is "long long" = "long long int" = "long int long" = "int long long"?

I found both long int long and int long long can compile for a variable type. Is there any difference between long int long, int long long , long long and long long int? In general, is the type identical if it has the same number of long? 1…
ggrr
  • 7,737
  • 5
  • 31
  • 53
158
votes
17 answers

Java: random long number in 0 <= x < n range

Random class has a method to generate random int in a given range. For example: Random r = new Random(); int x = r.nextInt(100); This would generate an int number more or equal to 0 and less than 100. I'd like to do exactly the same with long…
Vilius Normantas
  • 3,708
  • 6
  • 25
  • 38
139
votes
8 answers

How could I convert data from string to long in c#

How could i convert data from string to long in C#? I have data String strValue[i] ="1100.25"; now i want it in long l1;
MayureshP
  • 2,514
  • 6
  • 31
  • 41
137
votes
12 answers

Converting Long to Date in Java returns 1970

I have list with long values (for example: 1220227200, 1220832000, 1221436800...) which I downloaded from web service. I must convert it to Dates. Unfortunately this way, for example: Date d = new Date(1220227200); returns 1 Jan 1970. Anyone know…
mmmiki
  • 1,379
  • 2
  • 10
  • 5
117
votes
15 answers

How can I check if multiplying two numbers in Java will cause an overflow?

I want to handle the special case where multiplying two numbers together causes an overflow. The code looks something like this: int a = 20; long b = 30; // if a or b are big enough, this result will silently overflow long c = a * b; That's a…
Steve McLeod
  • 51,737
  • 47
  • 128
  • 184
1
2 3
99 100