Friday, 1 December 2017

Csharp LeftShift Operations


Code:

using System;
class sample
{
    public static void Main()
    {
        int x = 1024 * 1024 * 1024;
        uint p = 1024 * 1024 * 1024;
        int y = -42;
        Console.WriteLine("LEFT SHIFT OPERATIONS :");
        Console.WriteLine("{0},{1},{2}", x, x * 2, x << 1);
        Console.WriteLine("{0},{1},{2}", p, p * 2, p << 1);
        Console.WriteLine("{0},{1},{2}", x, x * 4, x << 2);
        Console.WriteLine("{0},{1},{2}", p, p * 4, p << 2);
        Console.WriteLine("{0},{1},{2}", y, y * 1024 * 1024 * 64, x << 26);
        Console.ReadLine();
    }
}


Output:

LEFT SHIFT OPERATIONS :
1073741824,-2147483648,-2147483648
1073741824,2147483648,2147483648
1073741824,0,0
1073741824,0,0
-42,1476395008,0



More C# Programs:
















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...