除法方法
使用以下原创代码请遵循协议.
Div()
Protected Function div(ByVal a As Integer, ByVal b As Integer) As String
Dim s As String = ""
If a < b Then
s = "0."
a = a * 10
Else
s = Int(a / b).ToString() & "."
a = a - Int(a / b) * b
a = a * 10
End If
Dim l As New List(Of Integer)
While Not l.Contains(a)
If Int(a / b) = 0 Then
a = a * 10
s &= "0"
Else
l.Add(a)
s &= Int(a / b).ToString()
a = a - Int(a / b) * b
a = a * 10
If a = 0 Then
Return s
End If
End If
End While
For i As Integer = 0 To l.Count - 1
If a = l(i) Then
s = s.Insert(i + 2, "[")
End If
Next
Return s & "]"
End Function
Dim s As String = ""
If a < b Then
s = "0."
a = a * 10
Else
s = Int(a / b).ToString() & "."
a = a - Int(a / b) * b
a = a * 10
End If
Dim l As New List(Of Integer)
While Not l.Contains(a)
If Int(a / b) = 0 Then
a = a * 10
s &= "0"
Else
l.Add(a)
s &= Int(a / b).ToString()
a = a - Int(a / b) * b
a = a * 10
If a = 0 Then
Return s
End If
End If
End While
For i As Integer = 0 To l.Count - 1
If a = l(i) Then
s = s.Insert(i + 2, "[")
End If
Next
Return s & "]"
End Function