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
14
votes
5 answers

JPQL: cast Long to String to perform LIKE search

I have the following JPQL query: SELECT il FROM InsiderList il WHERE ( il.deleteFlag IS NULL OR il.deleteFlag = '0' ) AND il.clientId = :clientId AND ( LOWER( il.name ) LIKE :searchTerm OR il.nbr LIKE :searchTerm OR LOWER(…
Kawu
  • 13,647
  • 34
  • 123
  • 195
14
votes
7 answers

How to handle arbitrarily large integers

I'm working on a programming language, and today I got the point where I could compile the factorial function(recursive), however due to the maximum size of an integer the largest I can get is factorial(12). What are some techniques for handling…
Alex Gaynor
  • 14,353
  • 9
  • 63
  • 113
14
votes
6 answers

Answer to a practice interview question

I'm just going through a bunch of C++ interview questions just to make sure there's nothing obvious that I don't know. So far I haven't found anything that I didn't know already, except this: long value; //some stuff value &= 0xFFFF; The question…
Peter Alexander
  • 53,344
  • 14
  • 119
  • 168
14
votes
8 answers

Java - Convert Human Readable Size to Bytes

I've found lots of information about converting raw byte information into a human-readable format, but I need to do the opposite, i.e. convert the String "1.6 GB" into the long value 1717990000. Is there an in-built/well-defined way to do this, or…
Dan Forbes
  • 2,734
  • 3
  • 30
  • 60
13
votes
6 answers

Wrong result by Java Math.pow

If you try to run the following code public class Main { public static void main(String[] args) { long a = (long)Math.pow(13, 15); System.out.println(a + " " + a%13); } } You will get "51185893014090752 8" The correct value of…
Maxim Mayers
  • 185
  • 2
  • 6
13
votes
7 answers

Compare two primitive long variables in java

The title is pretty self-explanatory. I'm moving from C# to Java. I have an object and a getter method which returns its ID. I want to compare the ids of two objects of the same type and check if the values of their ids are…
Dragan
  • 3,713
  • 12
  • 42
  • 59
13
votes
4 answers

Representing a 64 bit integer in GNU/Linux

I am using Ubuntu 10.10 (64 bit) with gcc and I wanted to use a 64 bit integer in my C++ program. On my system the outputs of sizeof(long), sizeof(long long int) and sizeof(int64_t) are all 8 bytes (64 bits). Which qualifier (long, long long, or…
smilingbuddha
  • 14,334
  • 33
  • 112
  • 189
13
votes
7 answers

Convert Double to Binary representation?

I tried to convert a double to its binary representation, but using this Long.toBinaryString(Double.doubleToRawLongBits(d)) doesn't help, since I have large numbers, that Long can't store them i.e 2^900.
Besnik
  • 141
  • 1
  • 1
  • 6
13
votes
3 answers

Why in Scala Long cannot in initialized to null whear as Integer can

I am creating my Scala bean which is a configuration to be loaded from a YML config. I want a long property to be null if not specified, but I'm facing below issue. Any idea why? startOffset: Integer = null scala> var endOffset: Long =…
mukh007
  • 339
  • 1
  • 6
  • 17
13
votes
6 answers

Why am I unable to store my data in long data type?

int power(int first,int second) { int counter1 = 0; long ret = 1; while (counter1 != second){ ret *= first; counter1 += 1; } return ret; } int main(int argc,char **argv) { long one = atol(argv[1]); …
Charana
  • 1,074
  • 1
  • 13
  • 26
13
votes
2 answers

How big is the precision loss converting long to double?

I have read in different post on stackoverflow and in the C# documentation, that converting long (or any other data type representing a number) to double loses precision. This is quite obvious due to the representation of floating point numbers. My…
user3712853
13
votes
3 answers

Why not use long for all integer values

In my Java class we have just learned about of each of the following primitive data types: byte short int long Since the long data type contains the most bits, wouldn't it make sense to exclusively use the long data type to avoid…
Robert Tossly
  • 613
  • 1
  • 6
  • 14
13
votes
3 answers

What is meant by the most restrictive type in C?

The book The C Programming Language talks about "the most restrictive type" in section 8.7, Example — A Storage Allocator: Although machines vary, for each machine there is a most restrictive type: if the most restrictive type can be stored at a…
user1886376
13
votes
3 answers

How to convert an unsigned long int to QVariant

I have realized that QVariant does not offer functionality for long and unsigned long. It offers conversions to int, unsigned int, long long and unsigned long long. We can find in current Desktop architectures that long and int are equivalent, but…
Antonio
  • 851
  • 2
  • 8
  • 17
13
votes
6 answers

java short,integer,long performance

I read that JVM stores internally short, integer and long as 4 bytes. I read it from an article from the year 2000, so I don't know how true it is now. For the newer JVMs, is there any performance gain in using short over integer/long? And did that…
bob
  • 563
  • 2
  • 7
  • 12