In C & C++, if right operand is negative when using `>>` and `<<` (shift right & shift left operator), behavior of program is undefined.
Consider following program:

```
#include <iostream>
int main()
{
    int s(9);
    std::cout<<(s<<-3);
}

```

g++ gives following warning:

```
[Warning] left shift count is negative [enabled by default]

```

MSVS 2010 gives following warning:

```
warning c4293: '<<' : shift count negative or too big, undefined behavior

```

Now I am curious about what happens in Java and C#?

I've tried following program

```
class left_shift_nagative
{
    public static void main(String args[])
    {
        int a=3;
        System.out.println(a<<-3);
        System.out.println(a>>-3);
    }
}

```

Outcome of program: 

```
1610612736
0

```

C#'s turn:

```
namespace left_shift_nagative
{
    class Program
    {
        static void Main(string[] args)
        {
            int s = 3;
            Console.WriteLine(s << -3);
            Console.WriteLine(s >> -3); 
        }
    }
}

```

Output: 

```
1610612736
0

```

How the output 1610612736 comes? What is happening here? What the Java Language Specification (JLS) and C# Language Specification or standard says about this? How << and >> operator works when negative shift count is given in Java & C#? How I got output 0 when right shift is used? I am really getting confused.