[CODE] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim Sum = 0
For i = 1 To 99
Sum = Sum + 1 / (i * (i + 1))
Next
Label1.Text = Sum
End Sub[/CODE]
答案就是0.99啊 没有错的啊!何必伪造呢
Dim i As Integer
Dim Sum = 0
For i = 1 To 99
Sum = Sum + 1 / (i * (i + 1))
Next
Label1.Text = Sum
End Sub[/CODE]
答案就是0.99啊 没有错的啊!何必伪造呢
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim Sum As Double = 0
For i = 1 To 99
Sum = Sum + 1 / (i * (i + 1))
Next
Label1.Text = Sum
End Sub
double的精度就够了, single的精度不够!
Dim i As Integer
Dim Sum As Double = 0
For i = 1 To 99
Sum = Sum + 1 / (i * (i + 1))
Next
Label1.Text = Sum
End Sub
[此贴子已经被作者于2007-8-29 9:19:21编辑过]