How to double a variable with bitwise shift left in C#

1 Answer

0 votes
using System;

public class Program
{
    public static void Main()
    {
        int num = 8;
        
        num = num << 1;  // This will double the value of num
        
        Console.WriteLine(num);
    }
}



/*
run:

16

*/

 



answered Mar 9, 2025 by avibootz

Related questions

1 answer 100 views
1 answer 100 views
1 answer 99 views
1 answer 95 views
1 answer 89 views
1 answer 102 views
1 answer 133 views
...