二進位數相乘
Solomon
posted @ 2010年9月08日 10:08
in Uncategorized
, 1842 阅读

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fileContents As String
fileContents = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\Test1.txt")
Dim d() = Split(fileContents, " x ")
Dim n1 = d(0), n2 = d(1)
Dim Len = n1.Length * 2
Dim str1 = Space(Len) & n1 & vbNewLine & Space(Len) & n2 & vbNewLine & "--------------------" & vbNewLine
For i As Integer = n1.Length To 1 Step -1
If Mid(n2, i, 1) = "0" Then
str1 = str1 & Space(len) & StrDup(n1.Length, "0") & vbNewLine
Else
str1 = str1 & Space(len) & n1 & vbNewLine
End If
len = len - 1
Next
Dim x = c10to2(c2to10(n1) * c2to10(n2))
str1 = str1 & "--------------------" & vbNewLine & Space(len) & x
My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\result1.txt", str1, False)
End
End Sub
Function c2to10(ByVal x As String)
Dim c = 0
Dim n = x.ToString
For i As Integer = n.Length To 1 Step -1
If Mid(n, i, 1) = "1" Then c = c + (2 ^ (n.Length - i))
Next
Return c
End Function
Function c10to2(ByVal y As String)
Dim x = Val(y)
Dim str1 = ""
Do Until x = 1 Or x = 0
str1 = IIf(x Mod 2 = 0, "0" & str1, "1" & str1)
x = x \ 2
Loop
str1 = IIf(x = 0, "0" & str1, "1" & str1)
Return str1
End Function
End Class
上課
半夜
2022年12月21日 22:21
The code for multiplying binary numbers is shared here. This code is designed to help students understand how to multiply engagement rings binary numbers. This code is not meant to be used for commercial purposes.
2023年1月01日 15:36
Binary multiplication is a bit different than what you're used to in decimal multiplication. As with all binary operations, you start by multiplying the first digit of the top number by the first digit of the bottom number, and so forth. However, you also have to keep track of the "carried over" bits. Whenever the product of two digits is greater than Effects of CBD Edibles 1, you take the carried over bit and add it to the next column.
2023年1月16日 13:39
The Skills Competition Simultaneous Formulas challenge is a great way to test your knowledge of mathematics. In this challenge, you will be given a list of simultaneous equations and asked to solve them. CBD coupon This is a great opportunity to show off your skills and knowledge of mathematics.