| 订阅 | 在线投稿
分享
 
 
 

大数运算(十)

来源:互联网网民  宽屏版  评论
2006-11-04 12:44:01

Author:水如烟

用户使用的大数运算类

这里只是简单提供。可以考虑让它自动分拆多线程。

BigInt.vb

<Serializable()> _

Public Class BigInt

Private gMath As New MathsUnit

Public Property StringValue() As StringValue

Get

'转换为原存储方式

Return gMath.StringValue.CopyTo(gMath.OrignalAddressInfo.UnitNum)

End Get

Set(ByVal value As StringValue)

gMath.StringValue = value

End Set

End Property

Public Function Clone() As BigInt

Return CommonFunction.Clone(Of BigInt)(Me)

End Function

Public Sub CopyFrom(ByVal bInt As BigInt)

gMath.CopyFrom(bInt.gMath)

End Sub

Public Sub Add(ByVal bInt As BigInt)

gMath.Add(bInt.gMath)

End Sub

Public Shared Operator +(ByVal a As BigInt, ByVal b As BigInt) As BigInt

Dim c As BigInt = a.Clone

c.Add(b)

Return c

End Operator

Public Sub Multy(ByVal bInt As BigInt)

gMath.Multy(bInt.gMath)

End Sub

Public Shared Operator *(ByVal a As BigInt, ByVal b As BigInt) As BigInt

Dim c As BigInt = a.Clone

c.Multy(b)

Return c

End Operator

End Class

代码下载:代码

 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
Author:[url=http://lzmtw.cnblogs.com/]水如烟[/url] 用户使用的大数运算类 这里只是简单提供。可以考虑让它自动分拆多线程。 BigInt.vb <Serializable()> _ Public Class BigInt Private gMath As New MathsUnit Public Property StringValue() As StringValue Get '转换为原存储方式 Return gMath.StringValue.CopyTo(gMath.OrignalAddressInfo.UnitNum) End Get Set(ByVal value As StringValue) gMath.StringValue = value End Set End Property Public Function Clone() As BigInt Return CommonFunction.Clone(Of BigInt)(Me) End Function Public Sub CopyFrom(ByVal bInt As BigInt) gMath.CopyFrom(bInt.gMath) End Sub Public Sub Add(ByVal bInt As BigInt) gMath.Add(bInt.gMath) End Sub Public Shared Operator +(ByVal a As BigInt, ByVal b As BigInt) As BigInt Dim c As BigInt = a.Clone c.Add(b) Return c End Operator Public Sub Multy(ByVal bInt As BigInt) gMath.Multy(bInt.gMath) End Sub Public Shared Operator *(ByVal a As BigInt, ByVal b As BigInt) As BigInt Dim c As BigInt = a.Clone c.Multy(b) Return c End Operator End Class 代码下载:[url=http://www.cnblogs.com/Files/LzmTW/BigIntWorks.rar]代码[/url]
󰈣󰈤
 
 
 
>>返回首页<<
 
 热帖排行
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
©2005- 王朝网络 版权所有