Primitive « bit « Java Data Type Q&A





1. In Java, is it safe to assume a certain size of the primitive types for bitwise operations?    stackoverflow.com

Given Java's "write once, run anywhere" paradigm and the fact that the Java tutorials give explicit bit sizes for all the primitive data types without the slightest hint that this is ...

2. Primitive DataType Casting in java - Internal Logic    stackoverflow.com

Guys i want to understand , how the widening or narrow implicit casting is internally implemented in java.I know that it involves bit fiddling. For example:

//implicit
int i =2400;
long a = (long)i; 

//Explicit ...

3. What does this mean "Narrowing a primitive truncates the high order bits"    stackoverflow.com

What does this mean "Narrowing a primitive truncates the high order bits"

4. Dumping the bit values of a primitive type    coderanch.com

The easy way is with Integer.toHexString() or Long.toHexString(). Unfortunately these don't bad the result with zeros, which is something you probably want to do if you're going to be writing multiple hex values one after another. And annoyingly, JDK 5's Formatter class doesn't seem to support zero-padding a hex string either. Not the way I'd want, anyway. You can do this: ...

5. Bit shifting long primitives - strange behavior    forums.oracle.com

Shifting int by N produces the same result as shifting it by N % 32. Shifting a long by N produces the same result as shifting it by N % 64. So you sihft your int 33, which is the same as shifting it 1, and then it gets promoted to a long when you assign it to newVal.

6. get bits from primitive types    forums.oracle.com