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
50
votes
4 answers

node.js - Is there any proper way to parse JSON with large numbers? (long, bigint, int64)

When I parse this little piece of JSON: { "value" : 9223372036854775807 } This is what I get: { hello: 9223372036854776000 } Is there any way to parse it properly?
tartakynov
  • 2,768
  • 3
  • 26
  • 23
46
votes
1 answer

How to cast Long to Int in Scala?

I'd like to use the folowing function to convert from Joda Time to Unix timestamp: def toUnixTimeStamp(dt : DateTime) : Int = { val millis = dt.getMillis val seconds = if(millis % 1000 == 0) millis / 1000 else { throw new…
Ivan
  • 63,011
  • 101
  • 250
  • 382
44
votes
3 answers

JPA entity id - primitive or object type (long or Long)

Should the ID of your Entity be long (primitive type) or Long (object type)? The ID is the primary key of my table and is never 'null' in the database. My co-workers suggest to use an Object Type Long. Hibernate Reverse Engineering tool generates a…
Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127
43
votes
6 answers

Convert from Long to date format

I want to convert Long value to String or Date in this format dd/mm/YYYY. I have this value in Long format: 1343805819061. It is possible to convert it to Date format?
HaOx
  • 1,839
  • 6
  • 26
  • 36
42
votes
6 answers

Break long word with CSS

I have a situation where there can be long words like 'hellowordsometext' or integer like '1234567891122' without any space in between. check this js please. http://jsfiddle.net/rzq5e/6/ how is it possible to break it in to next line after it reach…
dev1234
  • 5,376
  • 15
  • 56
  • 115
41
votes
6 answers

Long.getLong() failing, returning null to valid string

I've spent the past two hours debugging what seems extremely unlikely. I've stripped the method of a secondary Android Activity to exactly this: public void onClick(View v) { String str = "25"; long my_long = Long.getLong(str); } //…
SMBiggs
  • 11,034
  • 6
  • 68
  • 83
40
votes
11 answers

How to use long id in Rails applications?

How can I change the (default) type for ActiveRecord's IDs? int is not long enough, I would prefer long. I was surprised that there is no :long for the migrations - does one just use some decimal?
Björn
  • 1,183
  • 2
  • 13
  • 18
37
votes
2 answers

Why do these two multiplication operations give different results?

Why do I need to add an "L" letter to get the correct long value? And what is the other value? long oneYearWithL = 1000*60*60*24*365L; long oneYearWithoutL = 1000*60*60*24*365; System.out.println(oneYearWithL);//gives correct calculation result :…
fareed
  • 3,034
  • 6
  • 37
  • 65
34
votes
6 answers

Why can't I assign a 'long' a value of 4 billion?

I'm trying to declare a long value in Java, which unfortunately does not work. This is my code. It results in the following error message: "The literal 4294967296 of type int is out of range". long bytes = 4294967296; I need this value to make a…
Peter
  • 617
  • 1
  • 7
  • 13
34
votes
5 answers

Java : convert long to Timestamp

I know, how to convert a Timestamp to a long, with the getTime() method. Is there a method that convert a long to a TimeStamp?
Adam Sh
  • 8,137
  • 22
  • 60
  • 75
33
votes
10 answers

Generate random values in C#

How can I generate random Int64 and UInt64 values using the Random class in C#?
SyncMaster
  • 9,754
  • 34
  • 94
  • 137
33
votes
2 answers

Isn't an Int64 equal to a long in C#?

I have been playing around with SQL and databases in C# via SqlCeConnection. I have been using ExecuteReader to read results and BigInt values for record IDs which are read into Longs. Today I have been playing with SQL statements that use COUNT…
user427165
33
votes
3 answers

Why are 2 Long variables not equal with == operator in Java?

I got a very strange problem when I'm trying to compare 2 Long variables, they always show false and I can be sure they have the same number value by debugging in Eclipse: if (user.getId() == admin.getId()) { return true; // Always enter here }…
Brady Zhu
  • 1,305
  • 5
  • 21
  • 43
32
votes
3 answers

Unsigned long in Java

Currently, I am using signed values, -2^63 to 2^63-1. Now I need the same range (2 * 2^64), but with positive values only. I found the java documentations mentioning unsigned long, which suits this use. I tried to declare 2^64 to a Long wrapper…
Annapoorni D
  • 831
  • 2
  • 13
  • 30
32
votes
2 answers

Java: Is there a difference between L and l (lowercase L) when specifying a long?

When I specify a number to be a long with a constant value 400, is there any difference between using 400L and 400l? Does it have some relationship to the wrapper type? Is L used to get a wrapper Long and l for the primitive data type long?
Lippstadtfreak
  • 321
  • 1
  • 3
  • 3