当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET BigInteger构造函数代码示例

本文整理汇总了VB.NET中System.Numerics.BigInteger.BigInteger构造函数的典型用法代码示例。如果您正苦于以下问题:VB.NET BigInteger构造函数的具体用法?VB.NET BigInteger怎么用?VB.NET BigInteger使用的例子?那么, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在System.Numerics.BigInteger的用法示例。


在下文中一共展示了BigInteger构造函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: bytes

Dim bytes() As Byte = { 5, 4, 3, 2, 1 }
Dim number As New BigInteger(bytes)
Console.WriteLine("The value of number is {0} (or 0x{0:x}).", number)
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:3,代码来源:BigInteger

输出:

The value of number is 4328719365 (or 0x102030405).

示例2: positiveBytes

' Instantiate BigInteger values.
Dim positiveValue As BigInteger = BigInteger.Parse("4713143110832790377889")
Dim negativeValue As BigInteger = BigInteger.Add(-Int64.MaxValue, -60000) 
Dim positiveValue2, negativeValue2 As BigInteger

' Create two byte arrays.
Dim positiveBytes() As Byte = positiveValue.ToByteArray()
Dim negativeBytes() As Byte = negativeValue.ToByteArray()

' Instantiate new BigInteger from negativeBytes array.
Console.Write("Converted {0:N0} to the byte array ", negativeValue)
For Each byteValue As Byte In negativeBytes
   Console.Write("{0:X2} ", byteValue)
Next 
Console.WriteLine()
negativeValue2 = New BigInteger(negativeBytes)
Console.WriteLine("Converted the byte array to {0:N0}", negativeValue2)
Console.WriteLine()

' Instantiate new BigInteger from positiveBytes array.
Console.Write("Converted {0:N0} to the byte array ", positiveValue)
For Each byteValue As Byte In positiveBytes
   Console.Write("{0:X2} ", byteValue)
Next 
Console.WriteLine()
positiveValue2 = New BigInteger(positiveBytes)
Console.WriteLine("Converted the byte array to {0:N0}", positiveValue2)
Console.WriteLine()
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:28,代码来源:BigInteger

输出:

Converted -9,223,372,036,854,835,807 to the byte array A1 15 FF FF FF FF FF 7F FF
Converted the byte array to -9,223,372,036,854,835,807

Converted 4,713,143,110,832,790,377,889 to the byte array A1 15 FF FF FF FF FF 7F FF 00
Converted the byte array to 4,713,143,110,832,790,377,889

示例3: bytes

Dim originalNumber As ULong = UInt64.MaxValue
' Convert an unsigned integer to a byte array.
Dim bytes() As Byte = BitConverter.GetBytes(originalNumber)
' Determine whether the MSB of the highest-order byte is set.
If originalNumber > 0 And (bytes(bytes.Length - 1) And &h80) > 0 Then
   ' If the MSB is set, add one zero-value byte to the end of the array.
   ReDim Preserve bytes(bytes.Length)
End If

Dim newNumber As New BigInteger(bytes)
Console.WriteLine("Converted the UInt64 value {0:N0} to {1:N0}.", 
                  originalNumber, newNumber)
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:12,代码来源:BigInteger

输出:

Converted the UInt64 value 18,446,744,073,709,551,615 to 18,446,744,073,709,551,615.

示例4: decimalValues

Dim decimalValues() As Decimal = { -1790.533d, -15.1514d, 18903.79d, 9180098.003d }
For Each decimalValue As Decimal In decimalValues
   Dim number As New BigInteger(decimalValue)
   Console.WriteLine("Instantiated BigInteger value {0} from the Decimal value {1}.",
                     number, decimalValue)
Next
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:6,代码来源:BigInteger

输出:

Instantiated BigInteger value -1790 from the Decimal value -1790.533.
Instantiated BigInteger value -15 from the Decimal value -15.1514.
Instantiated BigInteger value 18903 from the Decimal value 18903.79.
Instantiated BigInteger value 9180098 from the Decimal value 9180098.003.

示例5: BigInteger

' Create a BigInteger from a large double value.
Dim doubleValue As Double = -6e20
Dim bigIntValue As New BigInteger(doubleValue)
Console.WriteLine("Original Double value: {0:N0}", doubleValue)
Console.WriteLine("Original BigInteger value: {0:N0}", bigIntValue)
' Increment and then display both values.
doubleValue += 1
bigIntValue += BigInteger.One
Console.WriteLine("Incremented Double value: {0:N0}", doubleValue)
Console.WriteLine("Incremented BigInteger value: {0:N0}", bigIntValue)
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:10,代码来源:BigInteger

输出:

Original Double value: -600,000,000,000,000,000,000
Original BigInteger value: -600,000,000,000,000,000,000
Incremented Double value: -600,000,000,000,000,000,000
Incremented BigInteger value: -599,999,999,999,999,999,999

示例6: integers

Dim integers() As Integer = { Int32.MinValue, -10534, -189, 0, 17, 113439,
                              Int32.MaxValue }
Dim constructed, assigned As BigInteger

For Each number As Integer In integers
   constructed = New BigInteger(number)
   assigned = number
   Console.WriteLine("{0} = {1}: {2}", constructed, assigned, 
                     constructed.Equals(assigned)) 
Next
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:10,代码来源:BigInteger

输出:

-2147483648 = -2147483648: True
-10534 = -10534: True
-189 = -189: True
0 = 0: True
17 = 17: True
113439 = 113439: True
2147483647 = 2147483647: True

示例7: longs

Dim longs() As Long = { Int64.MinValue, -10534, -189, 0, 17, 113439,
                              Int64.MaxValue }
Dim constructed, assigned As BigInteger

For Each number As Long In longs
   constructed = New BigInteger(number)
   assigned = number
   Console.WriteLine("{0} = {1}: {2}", constructed, assigned, 
                     constructed.Equals(assigned)) 
Next
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:10,代码来源:BigInteger

输出:

-2147483648 = -2147483648: True
-10534 = -10534: True
-189 = -189: True
0 = 0: True
17 = 17: True
113439 = 113439: True
2147483647 = 2147483647: True

示例8: BigInteger

' Create a BigInteger from a large negative Single value
Dim negativeSingle As Single = Single.MinValue
Dim negativeNumber As New BigInteger(negativeSingle)

Console.WriteLine(negativeSingle.ToString("N0"))
Console.WriteLine(negativeNumber.ToString("N0"))

negativeSingle += 1
negativeNumber += 1
Console.WriteLine(negativeSingle.ToString("N0"))
Console.WriteLine(negativeNumber.ToString("N0"))
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:11,代码来源:BigInteger

输出:

-340,282,300,000,000,000,000,000,000,000,000,000,000
-340,282,346,638,528,859,811,704,183,484,516,925,440
-340,282,300,000,000,000,000,000,000,000,000,000,000
-340,282,346,638,528,859,811,704,183,484,516,925,439

示例9: unsignedValues

Dim unsignedValues() As UInteger = { 0, 16704, 199365, UInt32.MaxValue }
For Each unsignedValue As UInteger In unsignedValues
   Dim constructedNumber As New BigInteger(unsignedValue)
   Dim assignedNumber As BigInteger = unsignedValue
   If constructedNumber.Equals(assignedNumber) Then
      Console.WriteLine("Both methods create a BigInteger whose value is {0:N0}.",
                        constructedNumber)
   Else
      Console.WriteLine("{0:N0} ≠ {1:N0}", constructedNumber, assignedNumber)
   End If                         
Next
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:11,代码来源:BigInteger

输出:

Both methods create a BigInteger whose value is 0.
Both methods create a BigInteger whose value is 16,704.
Both methods create a BigInteger whose value is 199,365.
Both methods create a BigInteger whose value is 4,294,967,295.

示例10: BigInteger

Dim unsignedValue As ULong = UInt64.MaxValue
Dim number As New BigInteger(unsignedValue)
Console.WriteLine(number.ToString("N0"))
开发者ID:VB.NET开发者,项目名称:System.Numerics,代码行数:3,代码来源:BigInteger

输出:

18,446,744,073,709,551,615


注:本文中的System.Numerics.BigInteger.BigInteger构造函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。