regarding bitwise shift in "eventloop.h"
Harry Tanama
pr0gm3r at gmail.com
Wed Aug 1 01:17:47 EDT 2007
Hi Experts,
I don't really understand the purpose of using bitwise left-shift in
constant value of PurpleInputCondition enum.
typedef enum
{
PURPLE_INPUT_READ = 1 << 0, /**< A read condition. */
PURPLE_INPUT_WRITE = 1 << 1 /**< A write condition. */
} PurpleInputCondition;
Could we just use these method instead?
typedef enum
{
PURPLE_INPUT_READ = 1, /**< A read condition. */
PURPLE_INPUT_WRITE = 2 /**< A write condition. */
} PurpleInputCondition;
When I google for bitwise shift, they said that bitwise shifts are more
efficient than the normal arithmetic operations.
Example: 4 << 2.
4 is 100 in binary. Adding 2 zeros to the end gives 10000, which is 16, i.e.
4*22 = 4*4 = 16.
I don't quiet understand why we're doing arithmetic binary in the
PURPLE_INPUT_READ = 1 << 0, and PURPLE_INPUT_WRITE = 1 << 1
Thank you for the explaination.
Kindes Regard,
pr0gm3r
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pidgin.im/pipermail/devel/attachments/20070731/0bda39c8/attachment.html>
More information about the Devel
mailing list