The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex
Vipan Singla's page on Bitwise Operations is quite nice.
ReplyDeleteIt is not language specific, but luckily, these operations work the same on Java as many languages (in particular, nearly all C-style languages work this way with bitwise operations). It is very visual, and uses tables to illustrate what happens by operation.
Additionally to the good introductory guide that Reed Copsey recommended I'd recommend a intresting collection of small real world samples that show what you can actually do with bit operators and that you might enjoy reading and experimenting with once you have got some basic understanding of how bitwise operators work.
ReplyDeleteRegarding the differences of bitwise operators between Java and C/C++: In Java you don't have unsigned numeric types (except char) but instead you have two right shift operators (>> and >>>) that allow you to do either a signed (>>) or a unsigned shift (>>>). A signed right shift copies the sign bit to all empty places on the left side while a unsigned right shift fills them with zero bits. Also, as booleans in Java cannot be be cast to ints, you cannot use boolean expressions directly as operands for bit operators. I.e. something like this works in C but not in Java:
val |= ( a > b );
In Java you would have to write this insead to do the same thing:
val |= ( a > b ) ? 1 : 0;
What's wrong with the WIkipedia article?
ReplyDeleteA perennial favorite: Sean Eron Anderson's Bit Twiddling Hacks.
ReplyDeleteAs an introduction to bitwise operations to represent sets and efficiently compute subsets I liked this tutorial. It contains links to samples, including Java code (if you keep following the links at the bottom of the linked pages).
ReplyDeleteAlso check Hacker's Delight, there is a sample chapter which is available online. Though not specific to Java, the programming tricks explained here would be applicable with Java also.
ReplyDelete