## Thursday, February 28, 2013

### Multiple skype instances on MACBOOK

Hi,

I have two skype id's and i had to login both of them simentaneously, so i opened up terminal and executed below command.

`sudo /Applications/Skype.app/Contents/MacOS/Skype /secondary `

Cheers,

Ujjwal Soni

### Absolute Beginner's Guide to Bit Shifting

The bit shifting operators do exactly what their name implies. They shift bits. Here's a brief (or not-so-brief) introduction to the different shift operators.

## The Operators

• `>>` is the arithmetic (or signed) right shift operator.
• `>>>` is the logical (or unsigned) right shift operator.
• `<<` is the left shift operator, and meets the needs of both logical and arithmetic shifts.

All of these operators can be applied to integer values (`int`, `long`, possibly `short` and `byte` or `char`). In some languages, applying the shift operators to any datatype smaller than `int` automatically resizes the operand to be an `int`.

Note that `<<<` is not an operator, because it would be redundant. Also note that C and C++ do not distingiush between the right shift operators. They provide only the `>>` operator, and the shifting behavior is implementation defined.

## Left shift (<<)

Integers are stored, in memory, as a series of bits. For example, the number 6 stored as a 32-bit `int` would be:

``````00000000 00000000 00000000 00000110
``````

Shifting this bit pattern to the left one position (`6 << 1`) would result in the number 12:

``````00000000 00000000 00000000 00001100
``````

As you can see, the digits have shifted to the left by one position, and the last digit on the right is filled with a zero. You might also note that shifting left is equivalent to multiplication by powers of 2. So `6 << 1` is equivalent to `6 * 2`, and `6 << 3` is equivalent to `6 * 8`. A good optimizing compiler will substitute shifts for multiplications when possible.

### Non-circular shifting

Please note that these are not circular shifts. Shifting this value to the left by one position (`3,758,096,384 << 1`):

``````11100000 00000000 00000000 00000000
``````

results in 3,221,225,472:

``````11000000 00000000 00000000 00000000
``````

The digit that gets shifted "off the end" is lost. It does not wrap around.

## Logical right shift (>>>)

A logical right shift is the converse to the left shift. Rather than moving bits to the left, they simply move to the right. For example, shifting the number 12:

``````00000000 00000000 00000000 00001100
``````

to the right by one position (`12 >>> 1`) will get back our original 6:

``````00000000 00000000 00000000 00000110
``````

So we see that shifting to the right is equivalent to division by powers of 2.

### Lost bits are gone

However, a shift cannot reclaim "lost" bits. For example, if we shift this pattern:

``````00111000 00000000 00000000 00000110
``````

to the left 4 positions (`939,524,102 << 4`), we get 2,147,483,744:

``````10000000 00000000 00000000 01100000
``````

and then shifting back (`(939,524,102 << 4) >>> 4`) we get 134,217,734:

``````00001000 00000000 00000000 00000110
``````

We cannot get back our original value once we have lost bits.

# Arithmetic right shift (>>)

The arithmetic right shift is exactly like the logical right shift, except instead of padding with zero, it pads with the most significant bit. This is because the most significant bit is the sign bit, or the bit that distinguishes positive and negative numbers. By padding with the most significant bit, the arithmetic right shift is sign-preserving.

For example, if we interpret this bit pattern as a negative number:

``````10000000 00000000 00000000 01100000
``````

we have the number -2,147,483,552. Shifting this to the right 4 positions with the arithmetic shift (-2,147,483,552 >> 4) would give us:

``````11111000 00000000 00000000 00000110
``````

or the number -134,217,722.

So we see that we have preserved the sign of our negative numbers by using the arithmetic right shift, rather than the logical right shift. And once again, we see that we are performing division by powers of 2.

### My first AVR LED Blink program in C

Hi,

I recieved my AVR programmer device last week so, i wrote my first LED blinking program in C (AVR). I used ATMEGA328P-PU chip. Earlier i have assembled my own arduino board so i used the same board for AVR by erasing the bootloader. below is my code

```#include <avr/io.h>
#include <util/delay.h>

/*
@author Ujjwal Soni
Connect a LED between pin 13 and GND.
*/

void delay()
{
unsigned char counter = 0;
while (counter != 50)
{
/* wait (30000 x 4) cycles = wait 120000 cycles */
_delay_loop_2(30000);
counter++;
}
}

int main(void)
{
/* Initialization, set PB5 (arduino digital pin 13) as output */
DDRB |= (1<<PB5);

while (1)
{
PORTB |= (1<<PB5);  //arduino digital pin 5 -> 5V
delay();
PORTB &= ~(1<<PB5);  //arduino digital pin 5 -> GND
delay();
}
return 0;
} ```

Please note that my LED is connected on PIN13.
I will be also writing pushbutton code which i will be posting here soon.

Cheers,

Ujjwal Soni

### Experience with Joomla

Hi,

I used Joomla for developing a website. I found it very odd and tricky. I have also used liferay which is quite easy and straight forward. You can share your experiences by commenting on my blog.

Thanks,

Ujjwal Soni

### Bypass site template in joomla article

Hi,

Recently i wanted to bypass site template for a particular joomla article for a site. I found below method that i would like to share with you :

Include a parameter :: ?tmpl=component in your article URL.

Thanks,

Ujjwal Soni

## Sunday, February 24, 2013

### Atmel® Studio 6 not supporting com ports with value greater than 9

Hi All,

I had been into a trouble with communicating my AVR programmer and Atmel Studio version 6, it gave an error saying that "Unable to connect com20". Later on i found that Atmel Studio version 6 has a problem with identifying devices with com port value > 9.

So, as a solution, i changed com port value to 8 and all worked fine.

So, if you face this similar issue, simply change value of com port by un-installing other com ports and enable the one where avr programmer is connected.

Cheers,

Ujjwal Soni
http://dbo-mechta.ru/    | http://dbo-mechta.ru/    |