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

hibernate returning BigDecimal datatype instead of long

The hibernate named query returns a BigDecimal for a column that has datatype NUMBER. select col1 as "col1" from table1 union select col2 as "col1" from table2 On client side, I expect the datatype of col1 to be long (primitive) I do…
Victor
  • 16,609
  • 71
  • 229
  • 409
11
votes
5 answers

How to add long value to calendar?

Calendar's add method in Java takes an integer as an input int secs = 3; cal.add(Calendar.SECOND, secs); But what if the seconds are Long type. long secs = 3 There's quite a few possibilities like adding the seconds iterative, but what are the…
Strudel
  • 809
  • 4
  • 10
  • 18
11
votes
3 answers

How to use 128 bit integers in Cython

On my 64 bit computer the long long type has 64 bits. print(sizeof(long long)) # prints 8 I need to use 128 bit integers and luckily GCC supports these. How can I use these within Cython? The following doesn't work. Compiling foo.pyx containing…
chtenb
  • 14,924
  • 14
  • 78
  • 116
11
votes
6 answers

How do I split up a long value (32 bits) into four char variables (8bits) using C?

I have a 32 bit long variable, CurrentPosition, that I want to split up into 4, 8bit characters. How would I do that most efficiently in C? I am working with an 8bit MCU, 8051 architectecture. unsigned long CurrentPosition = 7654321; unsigned char…
PICyourBrain
  • 9,976
  • 26
  • 91
  • 136
11
votes
2 answers

Java 8 - converting an Integer to a long compilation issue

I have the following abstract generic data holder in my project (simplified): public abstract static class Value { E value; public void setValue(E value) { this.value = value; } public E getValue() { return…
Ian2thedv
  • 2,691
  • 2
  • 26
  • 47
11
votes
6 answers

Subtracting long numbers in javascript

Why is q == 0 in the following script? I would think the result should be 10. What is the correct way to subtract these two…
Eric
  • 757
  • 5
  • 11
11
votes
3 answers

How to use long data type in Java?

I have to use quite a big number - 600851475143; as we all know, I have to use long data type but when I try to initialize like: long number = 600851475143 I get an error: The literal 600851475143 of type int is out of range. It seems that I don't…
Paulius
  • 141
  • 1
  • 1
  • 6
11
votes
2 answers

Cross platform definition of 64 bit integers in C++ for Windows and Linux

I am trying to write cross-platform code in C++ for Windows(MinGW) and Linux(g++). I was used to define 64 bit integers in Linux as "long", but when I moved to MinGW, the sizeof(long) returned 4 bytes. Then I discovered that I can use "long long" or…
Jaime Ivan Cervantes
  • 3,579
  • 1
  • 40
  • 38
11
votes
8 answers

Is it good to store long strings in a database?

I need to store long strings in a database. the string may be 5 or 6 sentences long. do you think this is a good design strategy. or should I store an id for that string and then create a relationship with another table that contains the location of…
Rohit Banga
  • 18,458
  • 31
  • 113
  • 191
11
votes
5 answers

Java: many ways of casting a (long) Object to double

I have an Object obj that I know is actually a long. In some Math code I need it as double. Is it safe to directly cast it to double? double x = (double)obj; Or should I rather cast it first to long and then to double. double x =…
Juve
  • 10,584
  • 14
  • 63
  • 90
10
votes
3 answers

Java RSA Encryption

I am trying to encode a simple String "test" back and forth. public static String encode(Key publicKey, String data) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { …
arik
  • 28,170
  • 36
  • 100
  • 156
10
votes
1 answer

Implementation of 32-bit floats or 64-bit longs in JavaScript?

Does anyone know of a JavaScript library that accurately implements the IEEE 754 specification for 32-bit floating-point values? I'm asking because I'm trying to write a cross-compiler in JavaScript, and since the source language has strict…
templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
10
votes
11 answers

Getting the second digit from a long variable

I am trying to fetch second digit from a long variable. long mi = 110000000; int firstDigit = 0; String numStr = Long.toString(mi); for (int i = 0; i < numStr.length(); i++) { System.out.println("" + i + " " + numStr.charAt(i)); firstDigit =…
shree
  • 341
  • 4
  • 13
10
votes
3 answers

64-bit Float Literals PHP

I'm trying to convert a 64-bit float to a 64-bit integer (and back) in php. I need to preserve the bytes, so I'm using the pack and unpack functions. The functionality I'm looking for is basically Java's Double.doubleToLongBits() method.…
kryo
  • 716
  • 1
  • 6
  • 24
10
votes
3 answers

Format a number to display a comma when larger than a thousand

I am writing some code in Visual Basic.net and have a question. If I have a long number, that is larger than 1000, how can I format this value to be 1,000 (with a comma) and for this to be stored in a string? For e.g. 1234 will be stored as…
Simon
  • 351
  • 3
  • 8
  • 16