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

Why does writing a number in scientific notation make a difference in this code?

I am trying to write a code to determine when the number of milliseconds since the beginning of 1970 will exceed the capacity of a long. The following code appears to do the job: public class Y2K { public static void main(String[] args) { …
sedeh
  • 7,083
  • 6
  • 48
  • 65
22
votes
1 answer

Proper way of converting string to long int in PHP

I tried (int) "4209531264" and intval("4209531264") but sadly all I get is 2147483647 (I realize this is because of 32 bit architecture or some php dependencies or something). I came up with "4209531264" + 0 which returns the correct result but it…
Maciej Jankowski
  • 2,794
  • 3
  • 26
  • 33
22
votes
2 answers

Why does java.util.zip.CRC32.getValue() return a long, not an int?

See the title. The returned value is 32 bits, right? Why not return an int?
Steveo
  • 2,238
  • 1
  • 21
  • 34
22
votes
5 answers

Why does C# allow an *implicit* conversion from Long to Float, when this could lose precision?

A similar question Long in Float, why? here does not answer what I am searching for. C# standard allows implicit conversion from long to float. But any long greater than 2^24 when represented as a float is bound to lose its 'value'. C# standard…
Amit Mittal
  • 2,646
  • 16
  • 24
21
votes
3 answers

Multiplication of two integers in C++

I have a pretty basic question, but I am not sure if I understand the concept or not. Suppose we have: int a = 1000000; int b = 1000000; long long c = a * b; When I run this, c shows negative value, so I changed also a and b to long long and then…
essa
  • 213
  • 1
  • 2
  • 6
21
votes
4 answers

In Swift, how do you convert a String to Int64?

I am loading in lines from a text file with very large numbers. String has the toInt method, but how do you convert a string to an Int64 which will be able to handle the large numbers? I don't see a toInt64 method or a toLong etc. There must be a…
shim
  • 9,289
  • 12
  • 69
  • 108
21
votes
3 answers

What's the difference between unsigned long/long/int in c/c++?

It seems all of them take 4 bytes of space, so what's the difference?
user198729
  • 61,774
  • 108
  • 250
  • 348
21
votes
5 answers

Convert a Long to base 36 in scala

How can I convert a Long to base36 ? Along with your answer can explain how you came to the answer? I've checked the scaladocs for Long for converting to a different base, and on converting a Long to a BigInt. I saw that BigInt does have toString(…
AKnox
  • 2,455
  • 3
  • 19
  • 19
20
votes
1 answer

how to serialize long to string with jackson?

jackson serializes long x = 1234 to {x:1234} For several reasons I need {x:"1234"} any jackson annotation? thanks.
ramon_salla
  • 1,587
  • 1
  • 17
  • 35
20
votes
4 answers

Hibernate returns BigIntegers instead of longs

This is my Sender entity @Entity public class Sender { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long senderId; ... ... public long getSenderId() { return senderId; } public void…
Tristan Van Poucke
  • 323
  • 1
  • 3
  • 14
20
votes
3 answers

What happened between March 28th and March 29th, 1976 with the java.util.GregorianCalendar?

Trying to use the GregorianCalendar, I got stuck on a singularity while computing the number of days since a particular date. In the scala interpreter, I entered : scala>import java.util.GregorianCalendar scala>import java.util.Calendar scala>val…
Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
19
votes
4 answers

Why in C# an explicit decimal => long conversion operator is called implicitly, losing precision?

The following C# program silently and implicitly calls an explicit decimal-to-long conversion operator, losing precision. I don't understand why this happens. As far as I understand, in C# explicit operator should not be called implicitly by the…
kaalus
  • 4,475
  • 3
  • 29
  • 39
19
votes
2 answers

Long to HEX string

I'm having trouble converting a hexadecimal number in a String to a long and then back again. Here's the code I'm using: private void parseExperiment(){ String str1 = "AA0F245C"; long nr = Long.parseLong(str1, 16); String str2 =…
Chikage
  • 281
  • 1
  • 3
  • 11
19
votes
4 answers

Will a long-integer work on a 32 bit system?

If I understand it right an int-variable is saving in 32 bit, restricting it to -2 billion to 2 billion something. However if I use a long-variable it will save in 64 bit allowing a lot more numbers to be stored. I'm sitting on a 64 bit system, but…
user3412636
  • 307
  • 1
  • 2
  • 9
19
votes
4 answers

C# equivalent of 64-bit unsigned long long in C++

I am building a DLL which will be used by C++ using COM. Please let me know what would be the C# equivalent of C++ 64-bit unsigned long long. Will it be ulong type in C# ? Please confirm. Thanks, Gagan
Gags
  • 827
  • 2
  • 13
  • 29