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
16
votes
2 answers

Java: Random long value in an interval

Possible Duplicate: Java: random long number in 0 <= x < n range I want to generate a random long value in an interval but it seems that the Random class nextLong() doesn't accept arguments like nextInt(). What can I do here?
Mintz
  • 929
  • 2
  • 11
  • 17
16
votes
5 answers

Getting a value of 0 when dividing 2 longs in c#

I am trying to divide the values of DriveInfo.AvailableFreeSpace & DriveInfo.TotalSize to try and get a percentage of it to use in a progress bar. I need the end value to be an int as progressbar.value requires an int and the above methods return a…
Zeratas
  • 1,005
  • 3
  • 17
  • 36
15
votes
4 answers

Initialize ArrayList

Why I can initialize ArrayList, like this: ArrayList x = new ArrayList(Arrays.asList(1,2)); But got Error when using: ArrayList x = new ArrayList(Arrays.asList(1,2));
Tony
  • 1,106
  • 1
  • 10
  • 17
15
votes
2 answers

Python 256bit Hash function with number output

I need a Hash function with a 256bit output (as long int). First I thought I could use SHA256 from the hashlib but it has an String Output and I need a number to calculate with. Converting the 32 Byte String to a long would work also but I didn't…
Steffen
  • 153
  • 1
  • 4
15
votes
5 answers

Long/Int in scala to hex string

With Integer.toString(1234567, 16).toUpperCase() // output: 12D68 could help to convert an Int to Hex string. How to do the same with Long? Long.toString(13690566117625, 16).toUpperCase() // but this will report error
mCY
  • 2,731
  • 7
  • 25
  • 43
15
votes
9 answers

Cast an Object To Long in Java

I am trying to convert a Object type to Long type in Java and I got as: public static Long castObjectToLong(Object object) { return ((Long)object).longValue(); When I run, it throws ClassCastException
Dat Tan Nguyen
  • 365
  • 1
  • 3
  • 12
15
votes
3 answers

Intellij long "integer value is too big" but in range of long.maxvalue

This might be a silly thing but how is this possible that compiler will show this while Long.Max = 9223372036854775807 ?
vach
  • 10,571
  • 12
  • 68
  • 106
15
votes
5 answers

int to long assignment

I have been trying this int and long conversion where I have tried assigning an int variable to a long variable. The code is as follows: public static void main(String []args){ int i = 1024; long j = i; long k = i*i*i*i; …
Shashish Chandra
  • 489
  • 2
  • 5
  • 20
15
votes
2 answers

JSON - simple get an Integer instead of Long

How to get an Integer instead of Long from JSON? I want to read JSON in my Java program, but when I get a JSON value which is a number, my parser returns a number of type Long. I want to get an Integer. I tried to cast the long to an integer, but…
user2190492
  • 1,174
  • 2
  • 9
  • 37
15
votes
4 answers

Python type long vs C 'long long'

I would like to represent a value as a 64bit signed long, such that values larger than (2**63)-1 are represented as negative, however Python long has infinite precision. Is there a 'quick' way for me to achieve this?
clark
  • 565
  • 2
  • 5
  • 14
15
votes
2 answers

C: Casting minimum 32-bit integer (-2147483648) to float gives positive number (2147483648.0)

I was working on an embedded project when I ran into something which I thought was strange behaviour. I managed to reproduce it on codepad (see below) to confirm, but don't have any other C compilers on my machine to try it on them. Scenario: I have…
avanzal
  • 153
  • 1
  • 6
14
votes
5 answers

How can i generate a long hash of a String?

I have a java applciation in which I want to generate long ids for strings (in order to store those strings in neo4j). In order to avoid data duplication, I would like to generate an id for each string stored in a long integer, which should be…
Riduidel
  • 22,052
  • 14
  • 85
  • 185
14
votes
4 answers

Eclipse: After Editing Long Lines Editor Window Automatically Scrolls to Beginning of Line

Some of my Javascript lines of code are longer than the editor window view. I have recently upgraded to the Helios version of Eclipse and noticed that after editing one of these long lines (I am scrolled to the right), after a few seconds the…
icats
  • 959
  • 3
  • 13
  • 24
14
votes
6 answers

Cannot implicitly convert type 'double' to 'long'

In this code i got the above error in lines i commented. public double bigzarb(long u, long v) { double n; long x; long y; long w; long z; string[] i = textBox7.Text.Split(','); long[] nums = new long[i.Length]; for…
Arash
  • 3,013
  • 10
  • 52
  • 74
14
votes
2 answers

Why does int(maxint) give a long, but int(int(maxint)) give an int? Is this a NumPy bug?

Pretty self-explanatory (I'm on Windows): >>> import sys, numpy >>> a = numpy.int_(sys.maxint) >>> int(a).__class__ >>> int(int(a)).__class__ Why does calling int once give me a long, whereas calling it twice gives me an…
user541686
  • 205,094
  • 128
  • 528
  • 886