本文整理匯總了VB.NET中System.Numerics.BigInteger.Abs方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET BigInteger.Abs方法的具體用法?VB.NET BigInteger.Abs怎麽用?VB.NET BigInteger.Abs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Numerics.BigInteger
的用法示例。
在下文中一共展示了BigInteger.Abs方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
' 導入命名空間
Imports System.IO
Imports System.Numerics
Imports System.Runtime.Serialization.Formatters.Binary
<Serializable> Public Structure SignAndMagnitude
Dim Sign As Integer
Dim Bytes() As Byte
End Structure
Module Example
Public Sub Main()
Dim fs As FileStream
Dim formatter As New BinaryFormatter()
Dim number As BigInteger = BigInteger.Pow(Int32.MaxValue, 20) * BigInteger.MinusOne
Console.WriteLine("The original value is {0}.", number)
Dim sm As New SignAndMagnitude()
sm.Sign = number.Sign
sm.Bytes = BigInteger.Abs(number).ToByteArray()
' Serialize SignAndMagnitude value.
fs = New FileStream(".\data.bin", FileMode.Create)
formatter.Serialize(fs, sm)
fs.Close()
' Deserialize SignAndMagnitude value.
fs = New FileStream(".\data.bin", FileMode.Open)
Dim smRestored As SignAndMagnitude = DirectCast(formatter.Deserialize(fs), SignAndMagnitude)
fs.Close()
Dim restoredNumber As New BigInteger(smRestored.Bytes)
restoredNumber *= sm.Sign
Console.WriteLine("The deserialized value is {0}.", restoredNumber)
End Sub
End Module
輸出:
The original value is -4.3510823966323432743748744058E+186. The deserialized value is -4.3510823966323432743748744058E+186.