本文整理汇总了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.