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

Java Converting long into currency

I am having trouble converting a long (cents) into currency format. My Code: long doublePayment = 1099; //Should equal $10.99 DecimalFormat dFormat = new DecimalFormat(); String formattedString =…
mcd
  • 6,446
  • 9
  • 27
  • 32
18
votes
4 answers

Java - parse and unsigned hex string into a signed long

I have a bunch of hex strings, one of them, for example is: d1bc4f7154ac9edb which is the hex value of "-3333702275990511909". This is the same hex you get if you do Long.toHexString("d1bc4f7154ac9edb"); For now, let's just assume I only have…
Peter
  • 837
  • 3
  • 14
  • 19
18
votes
6 answers

Why "long int" has same size as "int"? Does this modifier works at all?

Ehm.. I kind' of though this modifiers like long / short expands / reduces amount of memory allocated when variable are created, but... #include #define test_int int #define long_int long int #define long_long_int long long int void…
Kosmo零
  • 4,001
  • 9
  • 45
  • 88
18
votes
4 answers

Conversion IPv6 to long and long to IPv6

How should I perform conversion from IPv6 to long and vice versa? So far I have: public static long IPToLong(String addr) { String[] addrArray = addr.split("\\."); long num = 0; for (int i = 0; i <…
Testeross
  • 255
  • 1
  • 2
  • 9
17
votes
7 answers

What's the 'long' data type used for?

I've been programming in C++ for quite a while now and I am pretty familiar with most of the stuff. One thing that I've never understood though is the 'long' data type. I googled it but I still don't know what it is for. I've found pages that say it…
Alex
  • 241
  • 2
  • 3
  • 4
17
votes
3 answers

long vs Guid for the Id (Entity), what are the pros and cons

I am doing a web-application on asp.net mvc and I'm choosing between the long and Guid data type for my entities, but I don't know which one is better. Some say that long is much faster. Guid also might have some advantages. Anybody knows ?
Omu
  • 69,856
  • 92
  • 277
  • 407
17
votes
3 answers

Java code using HashSet of longs doesn't work?

This simple Java code adds 2 to a set of long, and subsequently prints whether 2 is a member of the set: import java.util.*; class A { public static void main(String[] args) { HashSet s = new HashSet(); long x = 2; …
Dog
  • 7,707
  • 8
  • 40
  • 74
16
votes
3 answers

What is the modulo operator for longs in Java?

How do I find the modulo (%) of two long values in Java? My code says 'Integer number too large' followed by the number I'm trying to mod. I tried casting it to a long but it didn't work. Do I have to convert it to a BigInteger and use the remainder…
Descartes
  • 503
  • 2
  • 7
  • 22
16
votes
4 answers

How to specify a BIGINT literal in T-SQL?

Aside from wrapping my literal in a CONVERT function, is there a way to specify that I want e.g. 12345 represented as a BIGINT and not an INT? In C#, I could specify 12345L, but I'm unaware of equivalent functionality in T-SQL.
Jason
  • 562
  • 2
  • 5
  • 13
16
votes
5 answers

How to display the maximum value of a unsigned long long in C?

What am I doing wrong here? $ cat size.c #include #include int main() { printf ("sizeof unsigned int = %d bytes.\n", sizeof(unsigned int)); printf ("sizeof unsigned long long = %d bytes.\n", sizeof(unsigned long long)); printf…
Lazer
  • 90,700
  • 113
  • 281
  • 364
16
votes
2 answers

Sane way to go from ArrayList through an Intent

I'm currently writing an app that pulls an array of longs from a server via json, and then passes that list from one activity into another. The basic skeleton looks like this: public void onResponse(Map result) { ArrayList handles=…
Kevin DiTraglia
  • 25,746
  • 19
  • 92
  • 138
16
votes
2 answers

Long Int literal - Invalid Syntax?

The Python tutorial book I'm using is slightly outdated, but I've decided to continue using it with the latest version of Python to practice debugging. Sometimes there are a few things in the book's code that I learn have changed in the updated…
Ziggy
  • 365
  • 2
  • 5
  • 13
16
votes
7 answers

Cannot convert from type object to long

I have a hashtable named table. The type value is long. I am getting values using .values(). Now I want to access these values. Collection val = table.values(); Iterator itr = val.iterator(); long a = (long)itr.next(); But when I try to get…
Mohit BAnsal
  • 1,571
  • 5
  • 16
  • 14
16
votes
4 answers

Why is the sizeof(int) == sizeof(long)?

In the program listed below, the sizeof(int) and sizeof(long) are equal on my machine (both equal 4 bytes (or 32 bits)). A long, as far as I know, is 8 bytes. Is this correct? I have a 64-bit machine #include #include int…
ChrisMcJava
  • 2,145
  • 5
  • 25
  • 33
16
votes
3 answers

Java: Why can't I declare integer types using scientific notation?

I can easily read 2e15 as "two quadrillion" at a glance, but for 2000000000000000 I have to count the zeroes, which takes longer and can lead to errors. Why can't I declare an int or long using a literal such as 2e9 or 1.3e6? I understand that a…
odougs
  • 175
  • 1
  • 1
  • 6