long « bit « Java Data Type Q&A

1. Java: How does the VM handle a 64bit `long` on a 32bit processor    stackoverflow.com

How does the JVM handle a primitive "long", which is 64bits, on a 32bit processor?

Can it utilise mulitple cores in parallel when on a Multi-Core 32bit machine?
How much slower are ...

2. How can I assemble bits into a long to create a unique ID?    stackoverflow.com

I would like to write a utility that will provide me with a relatively unique ID in Java. Something pretty simple, like x bits from timestamp + y bits from ...

3. Java: Checking if a bit is 0 or 1 in a long    stackoverflow.com

Given that : 0000000000000000000000000000000000000000000000000000000000000001 = 1 What method would you use to determine if the the bit that represents 2^x is a 1 or 0 ?

4. How to convert a long to a fixed-length 16-bit binary string?    stackoverflow.com

Hi i want to convert a long integer to binary but the problem is i want a fixed 16 bit binary result after conversion like if i convert 2 to 16 ...

5. 64bit MessageDigest - store short texts as long    stackoverflow.com

I want to represent short texts (ie word, couple of words) as a 64 bit hash (want to store them as longs) MessageDigest.getInstance("MD5") returns 128bits. Is there anything else I could use, could ...

6. Java: How to replace last 16 bits of a long with a short    stackoverflow.com

I have a long and a short I want the bits from the short to overwrite the low order 16 bits of the long. Ex (broken into 16bit chunks for readability):

> long = ...

7. bit twiddling in java - decomposing long into long[] of bitmasks    stackoverflow.com

I am decomposing a single long into a long[] of single bit longs by

public static int decompose(long[] buffer, long base) {
  int count = Long.bitCount(base);
  for (int i=0; i<count; ...

8. Number of bits used in long - java    stackoverflow.com

I want to know the number of bits really used in the long datatype in Java. For instance:

long time = System.currentTimeMillis();
12c95165393 Here you can see it only has ...

9. What would be the most performant (also safe) way to replace the last digit of a long?    stackoverflow.com

What would be the most performant (also safe) way to replace the last digit(Least significant digit) of a long(that was actually generated as timestamp by System.currentTimeInMillis()) by some other digit? Or is ...

10. 64 bit long ??    coderanch.com

So, I was trying to do a for loop earlier like this: for (long i = 0; i < 5000000000000; i++) /* Stuff goes here */ and I kept getting: integer number too large and I realized something... How the heck can a long be 64 bits on a 32 bit machine?? I mean, in every Java book I have been ...

11. How to get a 42 bit long number in Java.    coderanch.com

Java's long comprises of 63 bits where in the MSB is stored for the sign. I want to set 42nd bit of a particular number as 1. So I tried 1<<42, however this doesnt give the output as what I thought. neither did this work 1<<(42L). I am not supposed to use Strings and other wrapper class functions. Is there anyway ...

13. Trouble with parseInt() and a 32bit long string    forums.oracle.com

Perfect. New problem now though. when I convert something with Integer.parseInt(int,2), Whenever i try to do anything with it, any leading zeros dissappear. Without converting it to a string and simply concatenating a "0" to the beginning until it's long enough, is there a way to keep it at 32 bits long all the time??