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

Java's L number (long) specification

It appears that when you type in a number in Java, the compiler automatically reads it as an integer, which is why when you type in (long) 6000000000 (not in integer's range) it will complain that 6000000000 is not an integer. To correct this, I…
jbu
  • 15,831
  • 29
  • 82
  • 105
106
votes
7 answers

Division of integers in Java

This is a basic question but I can't find an answer. I've looked into floating point arithmetic and a few other topics but nothing has seemed to address this. I'm sure I just have the wrong terminology. Basically, I want to take two quantities -…
Ben
  • 54,723
  • 49
  • 178
  • 224
105
votes
5 answers

The literal xyz of type int is out of range

I am working with data types at the moment in Java, and if I have understood correctly the type long accepts a value between the ranges of -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807. Now as you can see below, I have create a long…
Mathew Donnan
  • 1,051
  • 2
  • 7
  • 3
104
votes
12 answers

Average of 3 long integers

I have 3 very large signed integers. long x = long.MaxValue; long y = long.MaxValue - 1; long z = long.MaxValue - 2; I want to calculate their truncated average. Expected average value is long.MaxValue - 1, which is 9223372036854775806. It is…
Ulugbek Umirov
  • 12,719
  • 3
  • 23
  • 31
103
votes
2 answers

How to convert a String to long in javascript?

I have a millisecond timestamp that I need to convert from a string to long. JavaScript has a parseInt but not a parseLong. So how can I do this? To expand on my question slightly: given that apparently JavaScript doesn't have a long type, how can I…
Richard H
  • 38,037
  • 37
  • 111
  • 138
101
votes
5 answers

Definition of int64_t

I am new to C/C++, so I have a couple of questions about a basic type: a) Can you explain to me the difference between int64_t and long (long int)? In my understanding, both are 64 bit integers. Is there any reason to choose one over the other? b)…
clstaudt
  • 21,436
  • 45
  • 156
  • 239
98
votes
5 answers

Why can't your switch statement data type be long, Java?

Here's an excerpt from Sun's Java tutorials: A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types (discussed in Classes and Inheritance) and a few special classes that "wrap" certain primitive…
Fostah
  • 11,398
  • 10
  • 46
  • 55
96
votes
8 answers

Why is long slower than int in x64 Java?

I'm running Windows 8.1 x64 with Java 7 update 45 x64 (no 32 bit Java installed) on a Surface Pro 2 tablet. The code below takes 1688ms when the type of i is a long and 109ms when i is an int. Why is long (a 64 bit type) an order of magnitude slower…
Techrocket9
  • 2,026
  • 3
  • 22
  • 33
89
votes
5 answers

long long in C/C++

I am trying this code on GNU's C++ compiler and am unable to understand its behaviour: #include ; int main() { int num1 = 1000000000; long num2 = 1000000000; long long num3; //num3 = 100000000000; long long num4 =…
sud03r
  • 19,109
  • 16
  • 77
  • 96
85
votes
9 answers

Why Use Integer Instead of Long?

I often see questions relating to Overflow errors with vba. My question is why use the integer variable declaration instead of just defining all numerical variables (excluding double etc.) as long? Unless you're performing an operation like in a for…
Gareth
  • 5,140
  • 5
  • 42
  • 73
81
votes
2 answers

Why does Math.ceil return a double?

When I call Math.ceil(5.2) the return is the double 6.0. My natural inclination was to think that Math.ceil(double a) would return a long. From the documentation: ceil(double a) Returns the smallest (closest to negative infinity) double value …
PengOne
  • 48,188
  • 17
  • 130
  • 149
81
votes
14 answers

Java: Checking if a bit is 0 or 1 in a long

What method would you use to determine if the the bit that represents 2^x is a 1 or 0 ?
Ande Turner
  • 7,096
  • 19
  • 80
  • 107
80
votes
5 answers

Long Vs. Int C/C++ - What's The Point?

As I've learned recently, a long in C/C++ is the same length as an int. To put it simply, why? It seems almost pointless to even include the datatype in the language. Does it have any uses specific to it that an int doesn't have? I know we can…
MGZero
  • 5,812
  • 5
  • 29
  • 46
77
votes
1 answer

NameError: global name 'long' is not defined

I have a Python version 3.3.0 and I am not sure why it does not let me do long for b and m here... I tried to look up the answers on here and but nothing helped...thanks im getting an error saying NameError: global name 'long' is not defined power…
Manual
  • 1,627
  • 5
  • 17
  • 20
75
votes
11 answers

wordwrap a very long string

How can you display a long string, website address, word or set of symbols with automatic line breaks to keep a div width? I guess a wordwrap of sorts. Usually adding a space works but is there a CSS solution such as word-wrap? For example it (very…
Peter Craig
  • 7,101
  • 19
  • 59
  • 74