Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Bitwise



  Why you should be careful about optimizations

In one of my current javascript projects, I have to deal with 3D voxel coordinates. And, sometimes, I have floating points coordinates which must be converted to integers in order to convert them into proper array index. Javascript is a wonderful language, really. However, implementations are sometimes weird, and the way to do something can sometimes have very huge impacts on the performances. Worse, sometimes the classical way is more expensive than the tricky one. So, some peo...

   JavaScript,Bitwise,Floor,Trick,Optimization     2012-05-02 11:29:20

  Implementation of +,-,*,/ with bitwise operator

There is a question asked on Stackoverflow : Divide a number by 3 without using *,/,+,-,% operators. This question is an Oracle interview question. Some people give excellent answers. You can go there and take a look. Usually we need to use bitwise operators to do this kind of implementations. Here I want to show you ways to implement +,-,*,/ with bitwise operators. A bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits. It is a fast, pr...

   Bitwise operator,Shift,Add,Subtract,Multiplication,Division     2012-08-05 01:52:47

  Hexadecimal and long in Java

Today I encountered a hexadecimal operation problem when I was implementing a bit reverse function for integer type. Basically in the implementation, there is an operation which is to do the bit operation & between one long integer and a hexadecimal number 0x00000000FFFFFFFFF. I was expecting that the high 32 bits of the long integer will be zeroed. But unfortunately I didn't get the expected result. The basic implementation is: long num=0x00F0_0000; num = (num>>16) | (num<<16); ...

   Hexadecimal,long,Java,bitwise operation     2014-06-18 23:44:32

  How to hide PHP Notice & Warning Messages

How to hide PHP Notice & Warning Messages. The PHP notice errors are frustrating and you are tired of seeing them when you are working on your scripts. They are showed at the beggining of your pages and may reveal confidential information to the visitor like the path to the file or the php file name in some cases.// Turn off all error reportingerror_reporting(0);// Report simple running errorserror_reporting(E_ERROR | E_WARNING | E_PARSE);// Reporting E_NOTICE can be good too (to report unin...

   PHP,Error,Warning,Deprecated,Hiding,Method     2011-11-18 12:17:26

  Valid JavaScript variable names

Did you know var π = Math.PI; is syntactically valid JavaScript? I thought this was pretty cool, so I decided to look into which Unicode glyphs are allowed in JavaScript variable names, or identifiers as the ECMAScript specification calls them. Reserved words The ECMAScript 5.1 spec says: An Identifier is an IdentifierName that is not a ReservedWord. The spec describes four groups of reserved words: keywords, future reserved words, null literals and boolean lite...

   JavaScript,Name convention,Standard     2012-02-22 05:16:53

  20 bit operations programmers should know

While talking about bit operation, programmers usually think about its efficiency. In embedded programming and system core optimization, appropriate use of bit operations is always a fascinating. When finding a job, it will help you a lot if you use bit operations when writing codes. Mastering simple bit arithmetic skills is necessary. 1. Get maximum int value int getMaxInt(){           return (1 << 31) - 1;//...

   Bit operation, Tips     2012-12-19 12:53:33

  Efficiency of code execution

If you want to optimize your program codes, you need to find their Hotspot, i.e, the codes which are executed most frequently. If you can optimize this portion of codes a bit, you may gain much improvement of your code efficiency. Here I give you three examples about efficiency of code execution.1. PHP's Getter and Setter (From Reddit)This example a quite simple, you can skip it if you want.Consider the code below, we can find it's slower when we use Getter/Setter method to read a member variabl...

   Code, Efficiency,Analysis,Trick     2012-07-13 10:59:21

  A re-introduction to JavaScript

Introduction Why a re-introduction? Because JavaScript has a reasonable claim to being the world's most misunderstood programming language. While often derided as a toy, beneath its deceptive simplicity lie some powerful language features. 2005 saw the launch of a number of high-profile JavaScript applications, showing that deeper knowledge of this technology is an important skill for any web developer. It's useful to start with an idea of the language's history. JavaScript was created in 1...

   JavaScript,Types,Array,Re-introduction,OOP     2012-02-09 05:38:08