bellyoshi

# πの計算

• R/O
• SSH
• HTTPS

## コミット

πの計算を行う。

### コミットメタ情報

リビジョン 1 (tree) 2014-09-12 13:42:59 bellyoshi

とりあえずコミット

### 差分

--- CALCPI/CALCPI/LongNum.vb (nonexistent)
+++ CALCPI/CALCPI/LongNum.vb (revision 1)
 @@ -0,0 +1,79 @@ 1 +﻿Public Class LongNum 2 + 3 + ''' 4 + ''' 算出桁数 5 + ''' 6 + ''' 7 + Public Const L As Integer = 1000 8 + 9 + ''' 10 + ''' 配列サイズ 11 + ''' 12 + ''' 13 + Private Const L1 As Integer = (L / 8) + 1 14 + 15 + ''' 16 + ''' 配列サイズ + 1 17 + ''' 18 + ''' 19 + Public Const L2 As Integer = L1 + 1 20 + 21 + ''' 22 + ''' 計算項数 23 + ''' 24 + ''' 25 + Public Const N As Integer = (L / 1.39794) + 1 26 + 27 + 28 + 29 + Public Function displayString(ByVal s() As Integer) As String 30 + Dim sb As New System.Text.StringBuilder 31 + sb.Append(s(0)) 32 + sb.Append(".") 33 + For i As Integer = 1 To s.Length - 1 34 + sb.Append(s(i)) 35 + Next 36 + Return sb.ToString 37 + End Function 38 + 39 + Public Sub ladd(ByVal a() As Integer, ByVal b() As Integer, ByVal c() As Integer) 40 + 41 + Dim carry As Integer = 0 42 + For i As Integer = L2 To 0 Step -1 43 + c(i) = a(i) + b(i) + carry 44 + If (c(i) < 100000000) Then 45 + carry = 0 46 + Else 47 + c(i) -= 100000000 48 + carry = 1 49 + End If 50 + Next 51 + 52 + End Sub 53 + 54 + 55 + 56 + Public Sub lsub(ByVal a() As Integer, ByVal b() As Integer, ByVal c() As Integer) 57 + Dim borrow As Integer = 0 58 + For i As Integer = L2 To 0 Step -1 59 + c(i) = a(i) - b(i) - borrow 60 + If (c(i) >= 0) Then 61 + borrow = 0 62 + Else 63 + c(i) += 100000000 64 + borrow = 1 65 + End If 66 + Next 67 + 68 + End Sub 69 + 70 + Public Sub ldiv(ByVal d() As Integer, ByVal e As Integer, ByVal f() As Integer) 71 + Dim r As Integer = 0 72 + For i As Integer = 0 To L2 73 + Dim w As Integer = d(i) 74 + f(i) = (w + r) \ e 75 + r = ((w + r) Mod e) * 100000000 76 + Next 77 + End Sub 78 + 79 +End Class
--- CALCPI/CALCPI/Module1.vb (nonexistent)
+++ CALCPI/CALCPI/Module1.vb (revision 1)
 @@ -0,0 +1,48 @@ 1 +﻿Module Module1 2 + 3 + Private a(LongNum.L2) As Integer 4 + Private b(LongNum.L2) As Integer 5 + Private s(LongNum.L2) As Integer 6 + Private q(LongNum.L2) As Integer 7 + Private lnum As New LongNum 8 + Sub Main() 9 + 10 + Try 11 + 12 + Calc() 13 + Console.WriteLine(lnum.displayString(s)) 14 + Catch ex As Exception 15 + Console.WriteLine("例外発生") 16 + Console.Write(ex.ToString) 17 + End Try 18 + Console.ReadKey() 19 + End Sub 20 + 21 + Private Sub Calc() 22 + For k As Integer = 0 To LongNum.L2 23 + s(k) = 0 24 + a(k) = 0 25 + b(k) = 0 26 + q(k) = 0 27 + Next 28 + 29 + a(0) = 16 * 5 30 + b(0) = 4 * 239 31 + 32 + For k As Integer = 1 To LongNum.N 33 + lnum.ldiv(a, 5 * 5, a) 34 + lnum.ldiv(b, 239 * 239, b) 35 + lnum.lsub(a, b, q) 36 + lnum.ldiv(q, 2 * k - 1, q) 37 + If k Mod 2 = 0 Then 38 + lnum.lsub(s, q, s) 39 + Else 40 + lnum.lsub(s, q, s) 41 + End If 42 + Next 43 + 44 + End Sub 45 + 46 + 47 + 48 +End Module
--- CALCPI/CALCPI/My Project/Resources.Designer.vb (nonexistent)
+++ CALCPI/CALCPI/My Project/Resources.Designer.vb (revision 1)
 @@ -0,0 +1,62 @@ 1 +﻿'------------------------------------------------------------------------------ 2 +' 3 +' This code was generated by a tool. 4 +' Runtime Version:4.0.30319.18444 5 +' 6 +' Changes to this file may cause incorrect behavior and will be lost if 7 +' the code is regenerated. 8 +' 9 +'------------------------------------------------------------------------------ 10 + 11 +Option Strict On 12 +Option Explicit On 13 + 14 + 15 +Namespace My.Resources 16 + 17 + 'This class was auto-generated by the StronglyTypedResourceBuilder 18 + 'class via a tool like ResGen or Visual Studio. 19 + 'To add or remove a member, edit your .ResX file then rerun ResGen 20 + 'with the /str option, or rebuild your VS project. 21 + ''' 22 + ''' A strongly-typed resource class, for looking up localized strings, etc. 23 + ''' 24 + _ 28 + Friend Module Resources 29 + 30 + Private resourceMan As Global.System.Resources.ResourceManager 31 + 32 + Private resourceCulture As Global.System.Globalization.CultureInfo 33 + 34 + ''' 35 + ''' Returns the cached ResourceManager instance used by this class. 36 + ''' 37 + _ 38 + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager 39 + Get 40 + If Object.ReferenceEquals(resourceMan, Nothing) Then 41 + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("CALCPI.Resources", GetType(Resources).Assembly) 42 + resourceMan = temp 43 + End If 44 + Return resourceMan 45 + End Get 46 + End Property 47 + 48 + ''' 49 + ''' Overrides the current thread's CurrentUICulture property for all 50 + ''' resource lookups using this strongly typed resource class. 51 + ''' 52 + _ 53 + Friend Property Culture() As Global.System.Globalization.CultureInfo 54 + Get 55 + Return resourceCulture 56 + End Get 57 + Set(ByVal value As Global.System.Globalization.CultureInfo) 58 + resourceCulture = value 59 + End Set 60 + End Property 61 + End Module 62 +End Namespace
--- CALCPI/CALCPI/My Project/AssemblyInfo.vb (nonexistent)
+++ CALCPI/CALCPI/My Project/AssemblyInfo.vb (revision 1)
 @@ -0,0 +1,35 @@ 1 +﻿Imports System 2 +Imports System.Reflection 3 +Imports System.Runtime.InteropServices 4 + 5 +' アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 6 +' アセンブリに関連付けられている情報を変更するには、 7 +' これらの属性値を変更してください。 8 + 9 +' アセンブリ属性の値を確認します。 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 +'このプロジェクトが COM に公開される場合、次の GUID がタイプ ライブラリの ID になります。 21 + 22 + 23 +' アセンブリのバージョン情報は、以下の 4 つの値で構成されています: 24 +' 25 +' Major Version 26 +' Minor Version 27 +' Build Number 28 +' Revision 29 +' 30 +' すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を 31 +' 既定値にすることができます: 32 +' 33 + 34 + 35 +
--- CALCPI/CALCPI/My Project/Settings.Designer.vb (nonexistent)
+++ CALCPI/CALCPI/My Project/Settings.Designer.vb (revision 1)
 @@ -0,0 +1,73 @@ 1 +﻿'------------------------------------------------------------------------------ 2 +' 3 +' This code was generated by a tool. 4 +' Runtime Version:4.0.30319.18444 5 +' 6 +' Changes to this file may cause incorrect behavior and will be lost if 7 +' the code is regenerated. 8 +' 9 +'------------------------------------------------------------------------------ 10 + 11 +Option Strict On 12 +Option Explicit On 13 + 14 + 15 +Namespace My 16 + 17 + _ 20 + Partial Friend NotInheritable Class MySettings 21 + Inherits Global.System.Configuration.ApplicationSettingsBase 22 + 23 + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) 24 + 25 +#Region "My.Settings Auto-Save Functionality" 26 +#If _MyType = "WindowsForms" Then 27 + Private Shared addedHandler As Boolean 28 + 29 + Private Shared addedHandlerLockObject As New Object 30 + 31 + _ 32 + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) 33 + If My.Application.SaveMySettingsOnExit Then 34 + My.Settings.Save() 35 + End If 36 + End Sub 37 +#End If 38 +#End Region 39 + 40 + Public Shared ReadOnly Property [Default]() As MySettings 41 + Get 42 + 43 +#If _MyType = "WindowsForms" Then 44 + If Not addedHandler Then 45 + SyncLock addedHandlerLockObject 46 + If Not addedHandler Then 47 + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings 48 + addedHandler = True 49 + End If 50 + End SyncLock 51 + End If 52 +#End If 53 + Return defaultInstance 54 + End Get 55 + End Property 56 + End Class 57 +End Namespace 58 + 59 +Namespace My 60 + 61 + _ 64 + Friend Module MySettingsProperty 65 + 66 + _ 67 + Friend ReadOnly Property Settings() As Global.CALCPI.My.MySettings 68 + Get 69 + Return Global.CALCPI.My.MySettings.Default 70 + End Get 71 + End Property 72 + End Module 73 +End Namespace
--- CALCPI/CALCPI/My Project/Application.Designer.vb (nonexistent)
+++ CALCPI/CALCPI/My Project/Application.Designer.vb (revision 1)
 @@ -0,0 +1,13 @@ 1 +﻿'------------------------------------------------------------------------------ 2 +' 3 +' This code was generated by a tool. 4 +' Runtime Version:4.0.30319.18444 5 +' 6 +' Changes to this file may cause incorrect behavior and will be lost if 7 +' the code is regenerated. 8 +' 9 +'------------------------------------------------------------------------------ 10 + 11 +Option Strict On 12 +Option Explicit On 13 +