1. Looking for a bitwise operator stackoverflow.comI have a list of objects of the same class. The order of the list is not important. What i want to do, is to (using bitwise operations) determine whether i should ... |
2. Bitwise shift operators. Signed and unsigned stackoverflow.comI'm practising for the SCJP exam using cram notes from the internet. According to my notes the ">>" operator is supposed to be signed right shift, with the sign bit being ... |
3. bitwise not operator stackoverflow.comWhy bitwise operation |
4. logical OR operator vs bitwise OR operator stackoverflow.comdoes anyone know why:
Print "True"
|
5. Unique number generation using shift operator and validate same with the bitwise & operator in java stackoverflow.comI'm using LEFT SHIFT operator from java to generate some unique number and validate same with the bitwise & operator like below.
|
6. Power of 2 bit operator in Java? stackoverflow.comI have a int variable to save the option, that may include none, one or many sub-options like this:
|
7. Difference between Bitwise and booolean operator 'AND' stackoverflow.comPossible Duplicates:As the title says, I need to know the ... |
8. Hexadecimal values and bitwise operators. coderanch.com |
9. difference between arithmetic operators and bitwise operators? coderanch.comWhat do you mean how are they different? The obvious answer is that they're defined differently and do different things. They take different operands to achieve the same result. 5 * 2.0 = 10.0 5 / 0.5 = 10.0 5 + 5.0 = 10.0 5 - (-5.0) = 10.0 They're different in the same way that all the above operators are ... |
10. Bit Operator coderanch.comI can't give an example, but I think you could them like a very primitive binary array - eg. 1100 would an array of 4 elements with 2 true/2 false. Memory isn't a big issue these days, but a few years back this was probably more useful because it uses so little space. |
11. Bit wise and shift operators coderanch.comSorry I couldn't think of a better example for the & operator. Basically, it is used to extract individual bits from a numeric type. public class Hair { public static void main( String[] args ) { // bit 3: 0 = oily, 1 = dry // bit 2: 0 = straight, 1 = curly // bit 1: 0 = ... |
12. Bitwise complement operator coderanch.comHi, I have an int x = 5; 0000 0000 0000 0000 0000 0000 0000 0101 ~x converts to: 1111 1111 1111 1111 1111 1111 1111 1010 Now, x = -6 WHY??? I know that the 32th digit represents the -ve sign. How to compute the number "6"? Thanks for help. Andrew |
13. Bit Level Operators coderanch.comSuppose you want to write a chess analyzing/playing engine. The coincidence that a long contains 64 bits and a chessboard contains 64 squares could (should?) ring a bell? Suppose you want to write a compression routine, where every single bit counts, do these bit-operators ring a bell? Suppose you want to manage a bunch of yes/no flags somewhere, and it needs ... |
14. Shift & Bitwise Operators coderanch.comCan someone provide me with some real world examples of where shift and bitwise operators might be used? I understand (kinda) what they are doing, but can't think of when they would be used. Also, is there a good webpage to explain them in more detail? I need to understand the whole shift and bitwise thing better. Thanks, John |
15. Bitwise and Shift Operators coderanch.com |
16. Importance of Bitwise Operators coderanch.comI've usually used them in other languages in much lower-level stuff, interpreting flags and bitmaps from the operating system. I made a little class to convert from IBM mainframe packed decimal to integer the other day that used shift, & and | operations, again pretty low-level. Any other typical applications out there? |
17. shift operator and bits coderanch.com |
18. A question about bitwise operator coderanch.comWelcome to JavaRanch, avseq! Take a look at the description of how the shift operators work from section 15.19 of the Java Language Specification. Note that it states, "If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were ... |
19. stuck in bitwise operators coderanch.comHi All, I am trying to create a file which i will later send to a cobol based machine . so i have to compress numbers in comp3 format. to achieve this i need to represent 2 numbers in one byte. eg to send the number 12 what i do is 0x0010 | 0x0002 which returns 0x0012 etc and write the ... |
20. Bitwise inversion operator (~) coderanch.comHi all, I have to small problem which I want clear off. I know for any integer the inversion value is (-X)-1, but need some more clarification on this. Say if you want to invert 18 first thing is to write it in the binary format that's; 1001 0010 then you change the 0s into 1s, and vice versa. which produces ... |
21. Doubts in basic bit wise operators. coderanch.comOriginally posted by dinesh Venkatesan: Hi All, Consider the following code: public class Tester { public static void main(String[] args) { int c = 2147483647; int d = ~c; System.out.println(c); System.out.println(d); } } The variable c contains the binary equivalent of 1111 1111 1111 1111 1111 1111 1111 1111. hence, ~c should result in 0000 0000 0000 0000 0000 0000 0000 ... |
22. Range of bitwise operators coderanch.comHi, When using java bitwise operators (such as bitwise-and "|", bitwise-xor "^") , i have just noticed that *int* is returned, even if the operands are bytes or shorts. For example: byte b1=3; byte b2=5; int result = b1 ^ b2; // byte^byte returns int int result = b1 | b2; // byte|byte returns int Would anyone please happen to know ... |
23. applications of bitwise operators coderanch.comHardware registers generally return values at certain bit locations. And of course, set value via bit locations. Graphics are done by turning on / off bits at particular bytes. Networking protocols uses particular bits in a packet. Disk drive protocols (ie. the SCSI CDB). Etc. IMHO, bit operators are probably not needed for high level application developers. The control of hardware, ... |
24. Bitwise operator " | " coderanch.comPlease note that in your example, | is not a bitwise operator but a logical OR operator. Whether | is one or the other depends on the argument type - if they are boolean it's logical, if they're numerical (not float or double) it's bitwise, any other case is a compile error. |
25. Output of Bitwise ~ operator ? coderanch.com |
26. Bitwise operator left shifting coderanch.comyes what joanne says is write because each bit is worth 2^n where n is equal the bit's position from the right starting from 0. so: 0000 00000 0000 1110 [Base-2] = 2^3 + 2^2 + 2^1 [Base-10] = 14 0000 00000 0000 0011 [Base-2] = 2^1 + 2^0 [Base-10] = 3 0000 00000 0011 1000 [Base-2] = 2^5 + 2^4 ... |
27. bitwise operators coderanch.comI am trying to find out how to set a bit and then inquire as to whether a bit is set. I would like to show the before and after with a System.out.println(); I believe I have to use the | operator and the shift right to set it and the & to inquire against it, but am not sure exactly ... |
28. bitwise operators issue coderanch.comWhen you operate on multiple integral values, they're all promoted to the same type -- usually int -- before the operations. So when you try to combine c and c2, you're actually combining (int) c and (int) c2. c2 is sign-extended with a prefix of all ones, not all zeros as you've shown. If you want to work with just an ... |
29. Right bit Shift Operator In Java coderanch.comIt seems I don't need to do this anyway...i misinterpreted the PHP code. The PHP code does the following: $bucket=((crc32($key)>>16)&0x7fff) % $this->bucketcount; ...and I thought that crc32 was returning a string...it turns out its returning a number. Now if I could only find a java CRC32 class that returned a number that matches the results of the PHP crc32 function... Would ... |
30. Diifference in Bitwise Operators coderanch.comIntegers are stored in two's complement format in Java (as in almost every other programming language). The leftmost bit of an int is the sign bit - if it's set, the number is negative, if it's cleared, the number is positive. The >> operator shifts all the bits of the operand to the right and fills in the new bits on ... |
31. bit shifting operator coderanch.comI was looking at following example from link http://www.jchq.net/certkey/0501certkey.htm >>> This would represent -1. If you click it back one more place it would show >>> 11111111 11111111 11111111 11111111 1111110 >>> Those examples are slightly oversimplified. Until I studied for the Java Programmers exam I had assumed that twos compliment representation only referred to the use of the leading bit ... |
32. Bit wise ,shift Operators practical usage coderanch.compublic class Utils { private static final String HEX_CHARS = "0123456789ABCDEF"; public static String toHexString( byte[] byteArray ) { byte[] result = new byte[ byteArray.length << 1 ]; int len = byteArray.length; for( int i = 0 ; i < len ; i++ ) { byte b = byteArray[ i ]; int lo4 = b & 0x0F; int hi4 = (b ... |
33. Confusing with bitwise NOT operator java-forums.org |
34. bitwise not ~ operator java-forums.orghi, i was just wondering what i'm doing wrong below with the ~ operator ... public class PiTest { public static void main (String[] args) { System.out.println(Pi.piR(2)); System.out.println(Pi.piI(2)); System.out.println(Pi.piI(420000)); } } class Pi { private int n; public static double piR(int n) { if (n < 1) return 0; double v = n; if ( v % 2 == 0) return ... |
35. where exactly bit shift operators are useful? java-forums.orgHi ti all, I am interested to know in which cases exactly << ,>> and >>> operators .I never used those operators in my programs or either i didn't any expressions working with those operators ,in some project examples which i had seen. Can u tell me in which case[in real world examples] they are used.I know what exactly they do, ... |
36. Bit Operators forums.oracle.com |
37. bitwise operators forums.oracle.comFirst, read this: http://en.wikipedia.org/wiki/Two%27s_complement Given that, you'll understand that the high bit is the sign bit. There are two ways to shift right: 1. Bitwise shift-right (shift-right zero-fill). 2. Arithmetic shift-right (shift-right sign-extend). The first option fills the high bits with zero as you shift right. The second option performs sign-extension, which means the high bit is used to fill in ... |
38. Bitwise Operators forums.oracle.comThere's many bitwise operators.. When I am reading about bitwise operators.. I tend to glaze my eyes over the text. Is it really necessary to know how to use bitwise operators? What's the purpose of bitwise operators in real life programming? I saw somewhere that its more efficient to "add" numbers using bitwise operators rather than the traditional way.. for example ... |
39. Using bitwise operators to swap individual bits forums.oracle.comI'm able to set or clear individual bits using masks, however I'm trying to figure out how I could go about swapping two bits using bitwise operators but I haven't been able to figure it out. For example, say I had int x = 37 which is 100101 in binary and I wanted to swap the 2nd and 3rd bits I'd ... |
40. can i get the example on bit shifting operators forums.oracle.com |
41. query regarding bitwise operator forums.oracle.comyes, 0x0000001 is hexadecimal for 1 and the bitwise AND operator masks everything except the last bit. Your example code however is worthless, since it first shifts all the bits out of the byte and then gets the least significant bit with the bitmasking, resulting in 0 always. If you shift it less, or don't shift it at all, you get ... |
42. should i worry about bitwise operators???? forums.oracle.comfolks i want your views on this issue. I am a fourth year computer science student. I've done several projects in Java and i am well familiar with its various API's. Having said that, i still cant get solutions using bitwise operators. What i mean is that if i see bitwise operators (shift, and, or) in the code, i will be ... |
43. Calculating CRC using bitwise operators forums.oracle.comHi All, I need to calculate CRC for my application. Logic we used for calculating CRC is 1) addition of data length,actual data,message id. (All These are stored in a byte array) int crcSum = dataToBeSend[1] + dataToBeSend[2] + dataToBeSend[3] + dataToBeSend[4] + dataToBeSend[5]; 2) Now converting this to binary format String crcSumBin = Integer.toBinaryString(crcSum) 3) Now I am getting binary ... |
44. Bitwise Operators - Different Output ? forums.oracle.comHello ! Can anyone please as to why these two different programs are giving different values ? Both are using Right Shift Operator >>> . The first shifts right the value a set to -1 to 24 bit positions giving a = 255 . But with the second program doing the same in a loop we start getting zero from the ... |
45. How do Bitwise Operators work? forums.oracle.com |
46. Bitwise And operator forums.oracle.com |