Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,933 questions

51,870 answers

573 users

How to use left shift (<<) operator in VB.NET

1 Answer

0 votes
Imports System

Public Class Program
    Public Shared Sub Main()
        Dim pattern As Short = 12
		Dim result1, result2, result3, result4, result5 As Short
		
		Console.WriteLine(Convert.ToString(pattern, 2).PadLeft(16, "0"c))
		
		result1 = pattern << 0
		result2 = pattern << 4
		result3 = pattern << 9
		result4 = pattern << 14
		result5 = pattern << -1
	
		Console.WriteLine(Convert.ToString(result1, 2).PadLeft(16, "0"c) & " " & result1)
		Console.WriteLine(Convert.ToString(result2, 2).PadLeft(16, "0"c) & " " & result2)
		Console.WriteLine(Convert.ToString(result3, 2).PadLeft(16, "0"c) & " " & result3)
		Console.WriteLine(Convert.ToString(result4, 2).PadLeft(16, "0"c) & " " & result4)
		Console.WriteLine(Convert.ToString(result5, 2).PadLeft(16, "0"c) & " " & result5)

    End Sub
End Class





' run:
'
' 0000000000001100
' 0000000000001100 12
' 0000000011000000 192
' 0001100000000000 6144
' 0000000000000000 0
' 0000000000000000 0
'

 



answered Aug 25, 2023 by avibootz

Related questions

1 answer 108 views
1 answer 80 views
1 answer 140 views
1 answer 122 views
122 views asked Sep 13, 2021 by avibootz
1 answer 262 views
2 answers 182 views
1 answer 181 views
...