{"id":194,"date":"2007-09-10T23:21:27","date_gmt":"2007-09-10T15:21:27","guid":{"rendered":"http:\/\/j178.mtgbb.com\/144"},"modified":"2007-09-10T23:21:27","modified_gmt":"2007-09-10T15:21:27","slug":"%e8%a8%88%e7%ae%97-pi","status":"publish","type":"post","link":"https:\/\/j178.mtgbb.com\/?p=194","title":{"rendered":"\u8a08\u7b97 pi"},"content":{"rendered":"<p>\u5176\u5be6\u662f VB6\uff0c\u66ab\u6642\u5148\u6b78\u985e\u5230 vb.net \u597d\u4e86<\/p>\n<p>\u7a0b\u5f0f\u5167\u5bb9:<br \/>\nmethod1\u662f\u5206\u958b\u7b97\u7684\uff0c\u52a0\u6cd5\u548c\u6e1b\u6cd5\u5206\u958b\uff0c\u6700\u5f8c\u52a0\u5728\u4e00\u8d77\uff0c<br \/>\nmethod2\u662f\u539f\u672c\u7684<br \/>\n\u6700\u5f8c\u6709\u5217\u5370\u51fa\uff0c\u8a08\u6578method1\u548cmethod2\u7684\u8a08\u7b97\u6642\u9593&#8230;<\/p>\n<p><!--more--><\/p>\n<pre lang=\"vb\" line=\"1\">\nPrivate Sub Form_Load()\nDim pi As Variant\nDim i As Long 'Single\nDim j As Variant\nDim k As Variant\nDim Start, Finish, TotalTime\n\npi = 0\nj = 0\nk = 0\n\nIf (MsgBox(\"Press Yes to start for pi calculation\", 4)) = vbYes Then\n\n'=============method1(divide calculate)====================\nStart = Timer\n\nFor i = 0 To 10000000 '2147483646\nj = j + CDec(1 \/ (4 * i + 1))\nNext i\n\nFor i = 1 To 10000000\nk = k - CDec(1 \/ (4 * i - 1))\nNext i\n\npi = j + k\npi = 4 * CDec(pi)\n\nFinish = Timer\nTotalTime = Finish - Start\n\nDebug.Print \"method1:\" &amp; pi\nDebug.Print \"method1 time:\" &amp; TotalTime\n\n'=============method2(original)====================\npi = 0\nStart = Timer\n\nFor i = 0 To 20000000 '2147483646\npi = pi + CDec(1 \/ (2 * i + 1) * (-1) ^ i)\nNext i\n\npi = 4 * CDec(pi)\n\nFinish = Timer\nTotalTime = Finish - Start\n\nDebug.Print \"method2:\" &amp; pi\nDebug.Print \"method2 time:\" &amp; TotalTime\nElse\nEnd\nEnd If\nEnd Sub\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5176\u5be6\u662f VB6\uff0c\u66ab\u6642\u5148\u6b78\u985e\u5230 vb.net \u597d\u4e86 \u7a0b\u5f0f\u5167\u5bb9: method1\u662f\u5206\u958b\u7b97\u7684\uff0c\u52a0\u6cd5\u548c\u6e1b\u6cd5\u5206\u958b\uff0c\u6700\u5f8c\u52a0 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[31],"class_list":["post-194","post","type-post","status-publish","format-standard","hentry","category-vs-net","tag-vb6"],"_links":{"self":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts\/194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=194"}],"version-history":[{"count":0,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts\/194\/revisions"}],"wp:attachment":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}